Update activitypub deliver

This commit is contained in:
Daniel Supernault 2019-03-07 23:46:38 -07:00
parent 691cc991c6
commit feeb60eb94
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 133 additions and 135 deletions

View file

@ -63,8 +63,6 @@ class StatusActivityPubDeliver implements ShouldQueue
$profile = $status->profile; $profile = $status->profile;
Cache::forget('status:transformer:media:attachments:'.$status->id);
$fractal = new Fractal\Manager(); $fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer()); $fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Item($status, new CreateNote()); $resource = new Fractal\Resource\Item($status, new CreateNote());
@ -94,10 +92,8 @@ class StatusActivityPubDeliver implements ShouldQueue
$pool = new Pool($client, $requests($audience), [ $pool = new Pool($client, $requests($audience), [
'concurrency' => config('pixelfed.ap_delivery_concurrency'), 'concurrency' => config('pixelfed.ap_delivery_concurrency'),
'fulfilled' => function ($response, $index) { 'fulfilled' => function ($response, $index) {
Log::info('AP:deliver:success - ' . json_encode($response));
}, },
'rejected' => function ($reason, $index) { 'rejected' => function ($reason, $index) {
Log::info('AP:deliver:rejected - ' . json_encode($reason));
} }
]); ]);

View file

@ -29,7 +29,6 @@ class Helpers {
public static function validateObject($data) public static function validateObject($data)
{ {
// todo: undo
$verbs = ['Create', 'Announce', 'Like', 'Follow', 'Delete', 'Accept', 'Reject', 'Undo']; $verbs = ['Create', 'Announce', 'Like', 'Follow', 'Delete', 'Accept', 'Reject', 'Undo'];
$valid = Validator::make($data, [ $valid = Validator::make($data, [
@ -302,6 +301,9 @@ class Helpers {
return Profile::whereUsername($id)->firstOrFail(); return Profile::whereUsername($id)->firstOrFail();
} }
$res = self::fetchProfileFromUrl($url); $res = self::fetchProfileFromUrl($url);
if(isset($res['id']) == false) {
return;
}
$domain = parse_url($res['id'], PHP_URL_HOST); $domain = parse_url($res['id'], PHP_URL_HOST);
$username = $res['preferredUsername']; $username = $res['preferredUsername'];
$remoteUsername = "@{$username}@{$domain}"; $remoteUsername = "@{$username}@{$domain}";