Use file.download to retrieve macro images in the IRC macro bot
Summary: Fixes T5884. Macro images are no longer public on most installs. We could generate tokens for them, but this (using Conduit to pull the file data) is easier and more correct. Test Plan: Logged a bot into IRC and had it spam part of a macro before being killed for flooding. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5884 Differential Revision: https://secure.phabricator.com/D10274
This commit is contained in:
@@ -72,7 +72,8 @@ final class MacroQueryConduitAPIMethod extends MacroConduitAPIMethod {
|
||||
'uri' => $file->getBestURI(),
|
||||
'phid' => $macro->getPHID(),
|
||||
'authorPHID' => $file->getAuthorPHID(),
|
||||
'dateCreated' => $file->getDateCreated(),
|
||||
'dateCreated' => $file->getDateCreated(),
|
||||
'filePHID' => $file->getPHID(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,17 @@ final class PhabricatorBotMacroHandler extends PhabricatorBotHandler {
|
||||
}
|
||||
|
||||
public function rasterize($macro, $size, $aspect) {
|
||||
$image = HTTPSFuture::loadContent($macro['uri']);
|
||||
try {
|
||||
$image = $this->getConduit()->callMethodSynchronous(
|
||||
'file.download',
|
||||
array(
|
||||
'phid' => $macro['filePHID'],
|
||||
));
|
||||
$image = base64_decode($image);
|
||||
} catch (Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$image) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user