forked from GNUsocial/gnu-social
[PLUGIN][ActivityPub] Only store a new object if there were no previous activities with it before
This commit is contained in:
parent
5196b669b9
commit
330e09f2d3
@ -81,11 +81,15 @@ class Activity extends Model
|
||||
$ap_act = ActivitypubActivity::getWithPK(['activity_uri' => $type_activity->get('id')]);
|
||||
if (is_null($ap_act)) {
|
||||
$actor = ActivityPub::getActorByUri($type_activity->get('actor'));
|
||||
// Store Object
|
||||
$obj = null;
|
||||
if (!$type_activity->has('object') || !$type_activity->get('object')->has('type')) {
|
||||
throw new InvalidArgumentException('Activity Object or Activity Object Type is missing.');
|
||||
}
|
||||
// Store Object if new
|
||||
$ap_act = ActivitypubActivity::getWithPK(['object_uri' => $type_activity->get('object')->get('id')]);
|
||||
if (!is_null($ap_act)) {
|
||||
$obj = $ap_act->getActivity()->getObject();
|
||||
} else {
|
||||
$obj = null;
|
||||
switch ($type_activity->get('object')->get('type')) {
|
||||
case 'Note':
|
||||
$obj = Note::fromJson($type_activity->get('object'), ['source' => $source, 'actor_uri' => $type_activity->get('actor'), 'actor_id' => $actor->getId()]);
|
||||
@ -97,6 +101,7 @@ class Activity extends Model
|
||||
break;
|
||||
}
|
||||
DB::persist($obj);
|
||||
}
|
||||
// Store Activity
|
||||
$act = GSActivity::create([
|
||||
'actor_id' => $actor->getId(),
|
||||
|
Loading…
Reference in New Issue
Block a user