Skip to content

Commit

Permalink
Updating urls on tweets
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasansei committed Apr 16, 2021
1 parent 8967e81 commit da03528
Showing 1 changed file with 24 additions and 75 deletions.
99 changes: 24 additions & 75 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,33 +277,6 @@ export default {
},


// sub puppetter_signed_url {
// my %config = @_;

// my $secret = $ENV{PUPPETER_SECRET_TOKEN};
// my $host = $ENV{PUPPETER_SERVICE_ROOT_URL};

// die 'missing PUPPETER_SECRET_TOKEN' if !$secret;
// die 'missing PUPPETER_SERVICE_ROOT_URL' if !$host;
// die 'invalid width' if $config{w} !~ /^\d+$/a;
// die 'invalid height' if exists $config{h} && $config{h} !~ /^\d+$/a;
// die 'invalid resize width' if exists $config{rw} && $config{rw} !~ /^\d+$/a;
// die 'invalid url' if $config{u} !~ /^http/i;

// my $my_url = Mojo::URL->new($host);

// my $calcBuffer = $secret . "\n";
// for my $field (keys %config) {
// $calcBuffer .= $field . '=' . $config{$field} . "\n";
// $my_url->query->merge($field, $config{$field});
// }

// my $calcSecret = md5_hex($calcBuffer);
// $my_url->query->merge('a', $calcSecret);

// return $my_url . '';
// }

buildAnalyzeReturn: async (extraDetails, lang) => {
// Setting text file
let texts;
Expand Down Expand Up @@ -589,22 +562,14 @@ export default {

const calcSecret = md5Hex(calcBuffer);

const pictureUrl = await (async () => {
try {
const res = await superagent
.get(puppetterUrl)
.query({
u: '' + tweetNeutral.url,
w: 480,
h: 520,
a: calcSecret,
});

return res.request.url;
} catch (err) {
console.error(err);
}
})();
const opts = {
u: '' + tweetNeutral.url,
w: 480,
h: 520,
a: calcSecret,
};
const queryString = new URLSearchParams(opts).toString();
const pictureUrl = `${puppetterUrl}?${queryString}`;

tweetSamples.push({
caption: "Exemplo de tweet neutro",
Expand All @@ -620,22 +585,14 @@ export default {

const calcSecret = md5Hex(calcBuffer);

const pictureUrl = await (async () => {
try {
const res = await superagent
.get(puppetterUrl)
.query({
u: '' + tweetPositive.url,
w: 480,
h: 520,
a: calcSecret,
});

return res.request.url;
} catch (err) {
console.error(err);
}
})();
const opts = {
u: '' + tweetPositive.url,
w: 480,
h: 520,
a: calcSecret,
};
const queryString = new URLSearchParams(opts).toString();
const pictureUrl = `${puppetterUrl}?${queryString}`;

tweetSamples.push({
caption: "Exemplo de tweet positivo",
Expand All @@ -651,22 +608,14 @@ export default {

const calcSecret = md5Hex(calcBuffer);

const pictureUrl = await (async () => {
try {
const res = await superagent
.get(puppetterUrl)
.query({
u: '' + tweetNegative.url,
w: 480,
h: 520,
a: calcSecret,
});

return res.request.url;
} catch (err) {
console.error(err);
}
})();
const opts = {
u: '' + tweetNegative.url,
w: 480,
h: 520,
a: calcSecret,
};
const queryString = new URLSearchParams(opts).toString();
const pictureUrl = `${puppetterUrl}?${queryString}`;

tweetSamples.push({
caption: "Exemplo de tweet negativo",
Expand Down

0 comments on commit da03528

Please sign in to comment.