mirror of
https://github.com/friendica/friendica
synced 2025-04-28 11:44:23 +02:00
Rewrite:
- moved constants GRAVITY_* from boot.php to Friendica\Model\Item - also rewrote some array initialization: From: ```` <?php $arr = []; $arr['foo'] = "FOO"; ```` To: ```` <?php $arr['foo'] = "FOO"; ```` - added a few type-hints
This commit is contained in:
parent
e5ae5c7e67
commit
da66730e4f
77 changed files with 547 additions and 513 deletions
|
@ -308,10 +308,10 @@ class Processor
|
|||
$item['thr-parent'] = $activity['reply-to-id'];
|
||||
|
||||
if ($activity['reply-to-id'] == $activity['id']) {
|
||||
$item['gravity'] = GRAVITY_PARENT;
|
||||
$item['gravity'] = Item::GRAVITY_PARENT;
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
} else {
|
||||
$item['gravity'] = GRAVITY_COMMENT;
|
||||
$item['gravity'] = Item::GRAVITY_COMMENT;
|
||||
$item['object-type'] = Activity\ObjectType::COMMENT;
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ class Processor
|
|||
|
||||
$item['diaspora_signed_text'] = $activity['diaspora:comment'] ?? '';
|
||||
|
||||
if (empty($conversation) && empty($activity['directmessage']) && ($item['gravity'] != GRAVITY_PARENT) && !Post::exists(['uri' => $item['thr-parent']])) {
|
||||
if (empty($conversation) && empty($activity['directmessage']) && ($item['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['uri' => $item['thr-parent']])) {
|
||||
Logger::notice('Parent not found, message will be discarded.', ['thr-parent' => $item['thr-parent']]);
|
||||
if (!$fetch_parents) {
|
||||
Queue::remove($activity);
|
||||
|
@ -663,7 +663,7 @@ class Processor
|
|||
|
||||
$item['verb'] = $verb;
|
||||
$item['thr-parent'] = $activity['object_id'];
|
||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||
$item['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
unset($item['post-type']);
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
||||
|
@ -833,7 +833,7 @@ class Processor
|
|||
$item['body'] = Item::improveSharedDataInBody($item);
|
||||
} else {
|
||||
$parent_uri = $item['parent-uri'] ?? $item['thr-parent'];
|
||||
if (empty($activity['directmessage']) && ($parent_uri != $item['uri']) && ($item['gravity'] == GRAVITY_COMMENT)) {
|
||||
if (empty($activity['directmessage']) && ($parent_uri != $item['uri']) && ($item['gravity'] == Item::GRAVITY_COMMENT)) {
|
||||
$parent = Post::selectFirst(['id', 'uri-id', 'private', 'author-link', 'alias'], ['uri' => $parent_uri]);
|
||||
if (!DBA::isResult($parent)) {
|
||||
Logger::warning('Unknown parent item.', ['uri' => $parent_uri]);
|
||||
|
@ -937,7 +937,7 @@ class Processor
|
|||
return true;
|
||||
}
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
// We cannot reliably check at this point if a comment or activity belongs to an accepted post or needs to be fetched
|
||||
// This can possibly be improved in the future.
|
||||
Logger::debug('Message is no parent - accepted', ['uri-id' => $item['uri-id'], 'guid' => $item['guid'], 'url' => $item['uri']]);
|
||||
|
@ -1035,7 +1035,7 @@ class Processor
|
|||
// When a post arrives via a relay and we follow the author, we have to override the causer.
|
||||
// Otherwise the system assumes that we follow the relay. (See "addRowInformation")
|
||||
Logger::debug('Relay post for follower', ['receiver' => $receiver, 'guid' => $item['guid'], 'relay' => $activity['from-relay']]);
|
||||
$item['causer-id'] = ($item['gravity'] == GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
|
||||
$item['causer-id'] = ($item['gravity'] == Item::GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
|
||||
}
|
||||
|
||||
if ($item['isForum'] ?? false) {
|
||||
|
@ -1053,7 +1053,7 @@ class Processor
|
|||
continue;
|
||||
}
|
||||
|
||||
if (($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT) && !in_array($item['post-reason'], [Item::PR_FOLLOWER, Item::PR_TAG, item::PR_TO, Item::PR_CC])) {
|
||||
if (($receiver != 0) && ($item['gravity'] == Item::GRAVITY_PARENT) && !in_array($item['post-reason'], [Item::PR_FOLLOWER, Item::PR_TAG, item::PR_TO, Item::PR_CC])) {
|
||||
if (!($item['isForum'] ?? false)) {
|
||||
if ($item['post-reason'] == Item::PR_BCC) {
|
||||
Logger::info('Top level post via BCC from a non sharer, ignoring', ['uid' => $receiver, 'contact' => $item['contact-id'], 'url' => $item['uri']]);
|
||||
|
@ -1088,7 +1088,7 @@ class Processor
|
|||
continue;
|
||||
}
|
||||
|
||||
if (($item['gravity'] != GRAVITY_ACTIVITY) && ($activity['object_type'] == 'as:Event')) {
|
||||
if (($item['gravity'] != Item::GRAVITY_ACTIVITY) && ($activity['object_type'] == 'as:Event')) {
|
||||
$event_id = self::createEvent($activity, $item);
|
||||
|
||||
$item = Event::getItemArrayForImportedId($event_id, $item);
|
||||
|
@ -1118,7 +1118,7 @@ class Processor
|
|||
}
|
||||
|
||||
// Store send a follow request for every reshare - but only when the item had been stored
|
||||
if ($stored && ($item['private'] != Item::PRIVATE) && ($item['gravity'] == GRAVITY_PARENT) && !empty($item['author-link']) && ($item['author-link'] != $item['owner-link'])) {
|
||||
if ($stored && ($item['private'] != Item::PRIVATE) && ($item['gravity'] == Item::GRAVITY_PARENT) && !empty($item['author-link']) && ($item['author-link'] != $item['owner-link'])) {
|
||||
$author = APContact::getByURL($item['owner-link'], false);
|
||||
// We send automatic follow requests for reshared messages. (We don't need though for forum posts)
|
||||
if ($author['type'] != 'Group') {
|
||||
|
@ -1138,7 +1138,7 @@ class Processor
|
|||
*/
|
||||
private static function hasParents(array $item, int $receiver)
|
||||
{
|
||||
if (($receiver == 0) || ($item['gravity'] == GRAVITY_PARENT)) {
|
||||
if (($receiver == 0) || ($item['gravity'] == Item::GRAVITY_PARENT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1149,7 +1149,7 @@ class Processor
|
|||
if ($item['verb'] != Activity::ANNOUNCE) {
|
||||
switch (DI::pConfig()->get($receiver, 'system', 'accept_only_sharer')) {
|
||||
case Item::COMPLETION_COMMENT:
|
||||
$add_parent = ($item['gravity'] != GRAVITY_ACTIVITY);
|
||||
$add_parent = ($item['gravity'] != Item::GRAVITY_ACTIVITY);
|
||||
break;
|
||||
|
||||
case Item::COMPLETION_NONE:
|
||||
|
@ -1283,7 +1283,7 @@ class Processor
|
|||
*/
|
||||
private static function postMail(array $activity, array $item)
|
||||
{
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && !DBA::exists('mail', ['uri' => $item['thr-parent'], 'uid' => $item['uid']])) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && !DBA::exists('mail', ['uri' => $item['thr-parent'], 'uid' => $item['uid']])) {
|
||||
Logger::info('Parent not found, mail will be discarded.', ['uid' => $item['uid'], 'uri' => $item['thr-parent']]);
|
||||
return false;
|
||||
}
|
||||
|
@ -1859,7 +1859,7 @@ class Processor
|
|||
return;
|
||||
}
|
||||
|
||||
Item::markForDeletion(['uri' => $activity['object_id'], 'author-id' => $author_id, 'gravity' => GRAVITY_ACTIVITY]);
|
||||
Item::markForDeletion(['uri' => $activity['object_id'], 'author-id' => $author_id, 'gravity' => Item::GRAVITY_ACTIVITY]);
|
||||
Queue::remove($activity);
|
||||
}
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ class Receiver
|
|||
}
|
||||
}
|
||||
|
||||
if (Post::exists(['uri' => $object_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]])) {
|
||||
if (Post::exists(['uri' => $object_id, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]])) {
|
||||
// We just assume "note" since it doesn't make a difference for the further processing
|
||||
return 'as:Note';
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ class Transmitter
|
|||
$condition = array_merge($condition, [
|
||||
'uid' => $owner['uid'],
|
||||
'author-id' => Contact::getIdForURL($owner['url'], 0, false),
|
||||
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
|
||||
'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT],
|
||||
'network' => Protocol::FEDERATED,
|
||||
'parent-network' => Protocol::FEDERATED,
|
||||
'origin' => true,
|
||||
|
@ -351,7 +351,7 @@ class Transmitter
|
|||
'uid' => $owner['uid'],
|
||||
'author-id' => $owner_cid,
|
||||
'private' => [Item::PUBLIC, Item::UNLISTED],
|
||||
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
|
||||
'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT],
|
||||
'network' => Protocol::FEDERATED,
|
||||
'parent-network' => Protocol::FEDERATED,
|
||||
'origin' => true,
|
||||
|
@ -577,7 +577,7 @@ class Transmitter
|
|||
$item_profile = APContact::getByURL($item['author-link']);
|
||||
$exclude[] = $item['author-link'];
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$exclude[] = $item['owner-link'];
|
||||
}
|
||||
|
||||
|
@ -665,7 +665,7 @@ class Transmitter
|
|||
|
||||
$data = ['to' => [], 'cc' => [], 'bcc' => []];
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$actor_profile = APContact::getByURL($item['owner-link']);
|
||||
} else {
|
||||
$actor_profile = APContact::getByURL($item['author-link']);
|
||||
|
@ -753,10 +753,10 @@ class Transmitter
|
|||
if (!empty($item['parent'])) {
|
||||
$parents = Post::select(['id', 'author-link', 'owner-link', 'gravity', 'uri'], ['parent' => $item['parent']], ['order' => ['id']]);
|
||||
while ($parent = Post::fetch($parents)) {
|
||||
if ($parent['gravity'] == GRAVITY_PARENT) {
|
||||
if ($parent['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$profile = APContact::getByURL($parent['owner-link'], false);
|
||||
if (!empty($profile)) {
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
// Comments to forums are directed to the forum
|
||||
// But comments to forums aren't directed to the followers collection
|
||||
// This rule is only valid when the actor isn't the forum.
|
||||
|
@ -971,7 +971,7 @@ class Transmitter
|
|||
|
||||
$inboxes = [];
|
||||
|
||||
if ($item['gravity'] == GRAVITY_ACTIVITY) {
|
||||
if ($item['gravity'] == Item::GRAVITY_ACTIVITY) {
|
||||
$item_profile = APContact::getByURL($item['author-link'], false);
|
||||
} else {
|
||||
$item_profile = APContact::getByURL($item['owner-link'], false);
|
||||
|
@ -1060,7 +1060,7 @@ class Transmitter
|
|||
$mail['parent-uri'] = $reply['uri'];
|
||||
$mail['parent-uri-id'] = $reply['uri-id'];
|
||||
$mail['parent-author-id'] = Contact::getIdForURL($reply['from-url'], 0, false);
|
||||
$mail['gravity'] = ($mail['reply'] ? GRAVITY_COMMENT: GRAVITY_PARENT);
|
||||
$mail['gravity'] = ($mail['reply'] ? Item::GRAVITY_COMMENT: Item::GRAVITY_PARENT);
|
||||
$mail['event-type'] = '';
|
||||
$mail['language'] = '';
|
||||
$mail['parent'] = 0;
|
||||
|
@ -1245,7 +1245,7 @@ class Transmitter
|
|||
if (!$object_mode) {
|
||||
$data = ['@context' => $context ?? ActivityPub::CONTEXT];
|
||||
|
||||
if ($item['deleted'] && ($item['gravity'] == GRAVITY_ACTIVITY)) {
|
||||
if ($item['deleted'] && ($item['gravity'] == Item::GRAVITY_ACTIVITY)) {
|
||||
$type = 'Undo';
|
||||
} elseif ($item['deleted']) {
|
||||
$type = 'Delete';
|
||||
|
@ -1256,7 +1256,7 @@ class Transmitter
|
|||
|
||||
if ($type == 'Delete') {
|
||||
$data['id'] = Item::newURI($item['guid']) . '/' . $type;;
|
||||
} elseif (($item['gravity'] == GRAVITY_ACTIVITY) && ($type != 'Undo')) {
|
||||
} elseif (($item['gravity'] == Item::GRAVITY_ACTIVITY) && ($type != 'Undo')) {
|
||||
$data['id'] = $item['uri'];
|
||||
} else {
|
||||
$data['id'] = $item['uri'] . '/' . $type;
|
||||
|
@ -1264,7 +1264,7 @@ class Transmitter
|
|||
|
||||
$data['type'] = $type;
|
||||
|
||||
if (($type != 'Announce') || ($item['gravity'] != GRAVITY_PARENT)) {
|
||||
if (($type != 'Announce') || ($item['gravity'] != Item::GRAVITY_PARENT)) {
|
||||
$data['actor'] = $item['author-link'];
|
||||
} else {
|
||||
$data['actor'] = $item['owner-link'];
|
||||
|
@ -1557,7 +1557,7 @@ class Transmitter
|
|||
// We are treating posts differently when they are directed to a community.
|
||||
// This is done to better support Lemmy. Most of the changes should work with other systems as well.
|
||||
// But to not risk compatibility issues we currently perform the changes only for communities.
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$isCommunityPost = !empty(Tag::getByURIId($item['uri-id'], [Tag::EXCLUSIVE_MENTION]));
|
||||
$links = Post\Media::getByURIId($item['uri-id'], [Post\Media::HTML]);
|
||||
if ($isCommunityPost && (count($links) == 1)) {
|
||||
|
|
|
@ -799,7 +799,7 @@ class DFRN
|
|||
$dfrnowner = self::addEntryAuthor($doc, "dfrn:owner", $item["owner-link"], $item);
|
||||
$entry->appendChild($dfrnowner);
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$parent = Post::selectFirst(['guid', 'plink'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
|
||||
if (DBA::isResult($parent)) {
|
||||
$attributes = ["ref" => $item['thr-parent'], "type" => "text/html",
|
||||
|
@ -888,7 +888,7 @@ class DFRN
|
|||
|
||||
if ($item['object-type'] != '') {
|
||||
XML::addElement($doc, $entry, 'activity:object-type', $item['object-type']);
|
||||
} elseif ($item['gravity'] == GRAVITY_PARENT) {
|
||||
} elseif ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
XML::addElement($doc, $entry, 'activity:object-type', Activity\ObjectType::NOTE);
|
||||
} else {
|
||||
XML::addElement($doc, $entry, 'activity:object-type', Activity\ObjectType::COMMENT);
|
||||
|
@ -1612,21 +1612,21 @@ class DFRN
|
|||
|| ($item['verb'] == Activity::ATTENDMAYBE)
|
||||
|| ($item['verb'] == Activity::ANNOUNCE)
|
||||
) {
|
||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||
$item['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
// only one like or dislike per person
|
||||
// split into two queries for performance issues
|
||||
$condition = [
|
||||
'uid' => $item['uid'],
|
||||
'author-id' => $item['author-id'],
|
||||
'gravity' => GRAVITY_ACTIVITY,
|
||||
'verb' => $item['verb'],
|
||||
'uid' => $item['uid'],
|
||||
'author-id' => $item['author-id'],
|
||||
'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'verb' => $item['verb'],
|
||||
'parent-uri' => $item['thr-parent'],
|
||||
];
|
||||
if (Post::exists($condition)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'gravity' => GRAVITY_ACTIVITY,
|
||||
$condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'verb' => $item['verb'], 'thr-parent' => $item['thr-parent']];
|
||||
if (Post::exists($condition)) {
|
||||
return false;
|
||||
|
@ -1938,7 +1938,7 @@ class DFRN
|
|||
|
||||
// Now assign the rest of the values that depend on the type of the message
|
||||
if (in_array($entrytype, [self::REPLY, self::REPLY_RC])) {
|
||||
$item['gravity'] = GRAVITY_COMMENT;
|
||||
$item['gravity'] = Item::GRAVITY_COMMENT;
|
||||
|
||||
if (!isset($item['object-type'])) {
|
||||
$item['object-type'] = Activity\ObjectType::COMMENT;
|
||||
|
@ -1964,7 +1964,7 @@ class DFRN
|
|||
if ($entrytype == self::REPLY_RC) {
|
||||
$item['wall'] = 1;
|
||||
} elseif ($entrytype == self::TOP_LEVEL) {
|
||||
$item['gravity'] = GRAVITY_PARENT;
|
||||
$item['gravity'] = Item::GRAVITY_PARENT;
|
||||
|
||||
if (!isset($item['object-type'])) {
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
@ -2034,7 +2034,7 @@ class DFRN
|
|||
Logger::info('Contact is not sharing with the user', ['uid' => $item['uid'], 'owner-id' => $item['owner-id'], 'author-id' => $item['author-id'], 'gravity' => $item['gravity'], 'uri' => $item['uri']]);
|
||||
return;
|
||||
}
|
||||
if (($item['gravity'] == GRAVITY_ACTIVITY) && DI::pConfig()->get($item['uid'], 'system', 'accept_only_sharer') == Item::COMPLETION_COMMENT) {
|
||||
if (($item['gravity'] == Item::GRAVITY_ACTIVITY) && DI::pConfig()->get($item['uid'], 'system', 'accept_only_sharer') == Item::COMPLETION_COMMENT) {
|
||||
Logger::info('Completion is set to "comment", but this is an activity. so we stop here.', ['uid' => $item['uid'], 'owner-id' => $item['owner-id'], 'author-id' => $item['author-id'], 'gravity' => $item['gravity'], 'uri' => $item['uri']]);
|
||||
return;
|
||||
}
|
||||
|
@ -2119,13 +2119,13 @@ class DFRN
|
|||
}
|
||||
|
||||
// When it is a starting post it has to belong to the person that wants to delete it
|
||||
if (($item['gravity'] == GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
|
||||
if (($item['gravity'] == Item::GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
|
||||
Logger::info('Item with URI ' . $uri . ' do not belong to contact ' . $importer['id'] . ' - ignoring deletion.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Comments can be deleted by the thread owner or comment owner
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
|
||||
$condition = ['id' => $item['parent'], 'contact-id' => $importer['id']];
|
||||
if (!Post::exists($condition)) {
|
||||
Logger::info('Item with URI ' . $uri . ' was not found or must not be deleted by contact ' . $importer['id'] . ' - ignoring deletion.');
|
||||
|
|
|
@ -83,7 +83,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$items = Post::select(['author-id', 'author-link', 'parent-author-link', 'parent-guid', 'guid'],
|
||||
['parent' => $item['parent'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
|
||||
['parent' => $item['parent'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]);
|
||||
while ($item = Post::fetch($items)) {
|
||||
$contact = DBA::selectFirst('contact', ['id', 'url', 'name', 'protocol', 'batch', 'network'],
|
||||
['id' => $item['author-id']]);
|
||||
|
@ -1548,7 +1548,7 @@ class Diaspora
|
|||
$datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
|
||||
|
||||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['gravity'] = GRAVITY_COMMENT;
|
||||
$datarray['gravity'] = Item::GRAVITY_COMMENT;
|
||||
|
||||
$datarray['thr-parent'] = $thr_parent ?: $toplevel_parent_item['uri'];
|
||||
|
||||
|
@ -1801,7 +1801,7 @@ class Diaspora
|
|||
$datarray['uri'] = self::getUriFromGuid($author, $guid);
|
||||
|
||||
$datarray['verb'] = $verb;
|
||||
$datarray['gravity'] = GRAVITY_ACTIVITY;
|
||||
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$datarray['thr-parent'] = $toplevel_parent_item['uri'];
|
||||
|
||||
$datarray['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
@ -1812,7 +1812,7 @@ class Diaspora
|
|||
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = DateTimeFormat::utcNow();
|
||||
|
||||
// like on comments have the comment as parent. So we need to fetch the toplevel parent
|
||||
if ($toplevel_parent_item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($toplevel_parent_item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$toplevel = Post::selectFirst(['origin'], ['id' => $toplevel_parent_item['parent']]);
|
||||
$origin = $toplevel['origin'];
|
||||
} else {
|
||||
|
@ -1981,7 +1981,7 @@ class Diaspora
|
|||
$datarray['uri'] = self::getUriFromGuid($author, $guid);
|
||||
|
||||
$datarray['verb'] = Activity::FOLLOW;
|
||||
$datarray['gravity'] = GRAVITY_ACTIVITY;
|
||||
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$datarray['thr-parent'] = $toplevel_parent_item['uri'];
|
||||
|
||||
$datarray['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
@ -2002,9 +2002,9 @@ class Diaspora
|
|||
|
||||
// Send all existing comments and likes to the requesting server
|
||||
$comments = Post::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb', 'gravity'],
|
||||
['parent' => $toplevel_parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
|
||||
['parent' => $toplevel_parent_item['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]);
|
||||
while ($comment = Post::fetch($comments)) {
|
||||
if (($comment['gravity'] == GRAVITY_ACTIVITY) && !in_array($comment['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
if (($comment['gravity'] == Item::GRAVITY_ACTIVITY) && !in_array($comment['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
Logger::info('Unsupported activities are not relayed', ['item' => $comment['id'], 'verb' => $comment['verb']]);
|
||||
continue;
|
||||
}
|
||||
|
@ -2302,7 +2302,7 @@ class Diaspora
|
|||
$datarray['thr-parent'] = $parent['uri'];
|
||||
|
||||
$datarray['verb'] = $datarray['body'] = Activity::ANNOUNCE;
|
||||
$datarray['gravity'] = GRAVITY_ACTIVITY;
|
||||
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$datarray['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
||||
$datarray['protocol'] = $item['protocol'];
|
||||
|
@ -2387,7 +2387,7 @@ class Diaspora
|
|||
$datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
|
||||
|
||||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['gravity'] = GRAVITY_PARENT;
|
||||
$datarray['gravity'] = Item::GRAVITY_PARENT;
|
||||
|
||||
$datarray['protocol'] = Conversation::PARCEL_DIASPORA;
|
||||
$datarray['source'] = $xml;
|
||||
|
@ -2706,7 +2706,7 @@ class Diaspora
|
|||
$datarray['owner-id'] = $datarray['author-id'];
|
||||
|
||||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['gravity'] = GRAVITY_PARENT;
|
||||
$datarray['gravity'] = Item::GRAVITY_PARENT;
|
||||
|
||||
$datarray['protocol'] = Conversation::PARCEL_DIASPORA;
|
||||
$datarray['source'] = $xml;
|
||||
|
@ -3596,7 +3596,7 @@ class Diaspora
|
|||
// - Implicit mentions are enabled
|
||||
if (
|
||||
$item['author-id'] != $thread_parent_item['author-id']
|
||||
&& ($thread_parent_item['gravity'] != GRAVITY_PARENT)
|
||||
&& ($thread_parent_item['gravity'] != Item::GRAVITY_PARENT)
|
||||
&& (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions'))
|
||||
&& !DI::config()->get('system', 'disable_implicit_mentions')
|
||||
) {
|
||||
|
@ -3729,7 +3729,7 @@ class Diaspora
|
|||
|
||||
$msg_type = 'retraction';
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$target_type = 'Post';
|
||||
} elseif (in_array($item['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
$target_type = 'Like';
|
||||
|
@ -4069,12 +4069,12 @@ class Diaspora
|
|||
return false;
|
||||
}
|
||||
|
||||
if (($parent_post['gravity'] == GRAVITY_COMMENT) && empty($parent_post['signed_text'])) {
|
||||
if (($parent_post['gravity'] == Item::GRAVITY_COMMENT) && empty($parent_post['signed_text'])) {
|
||||
Logger::info('Parent comment has got no Diaspora signature.', ['parent-id' => $parent_id]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($parent_post['gravity'] == GRAVITY_COMMENT) {
|
||||
if ($parent_post['gravity'] == Item::GRAVITY_COMMENT) {
|
||||
return self::parentSupportDiaspora($parent_post['thr-parent-id']);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,20 +252,21 @@ class Feed
|
|||
$author['owner-avatar'] = $contact['thumb'];
|
||||
}
|
||||
|
||||
$header = [];
|
||||
$header['uid'] = $importer['uid'] ?? 0;
|
||||
$header['network'] = Protocol::FEED;
|
||||
$header = [
|
||||
'uid' => $importer['uid'] ?? 0,
|
||||
'network' => Protocol::FEED,
|
||||
'wall' => 0,
|
||||
'origin' => 0,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'private' => Item::PUBLIC,
|
||||
'verb' => Activity::POST,
|
||||
'object-type' => Activity\ObjectType::NOTE,
|
||||
'post-type' => Item::PT_ARTICLE,
|
||||
'contact-id' => $contact['id'] ?? 0,
|
||||
];
|
||||
|
||||
$datarray['protocol'] = $protocol;
|
||||
$datarray['direction'] = Conversation::PULL;
|
||||
$header['wall'] = 0;
|
||||
$header['origin'] = 0;
|
||||
$header['gravity'] = GRAVITY_PARENT;
|
||||
$header['private'] = Item::PUBLIC;
|
||||
$header['verb'] = Activity::POST;
|
||||
$header['object-type'] = Activity\ObjectType::NOTE;
|
||||
$header['post-type'] = Item::PT_ARTICLE;
|
||||
|
||||
$header['contact-id'] = $contact['id'] ?? 0;
|
||||
|
||||
if (!is_object($entries)) {
|
||||
Logger::info("There are no entries in this feed.");
|
||||
|
@ -954,13 +955,13 @@ class Feed
|
|||
|
||||
$condition = ["`uid` = ? AND `received` > ? AND NOT `deleted` AND `gravity` IN (?, ?)
|
||||
AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?, ?, ?)",
|
||||
$owner['uid'], $check_date, GRAVITY_PARENT, GRAVITY_COMMENT,
|
||||
$owner['uid'], $check_date, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT,
|
||||
Item::PRIVATE, Protocol::ACTIVITYPUB,
|
||||
Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA];
|
||||
|
||||
if ($filter === 'comments') {
|
||||
$condition[0] .= " AND `gravity` = ? ";
|
||||
$condition[] = GRAVITY_COMMENT;
|
||||
$condition[] = Item::GRAVITY_COMMENT;
|
||||
}
|
||||
|
||||
if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
|
||||
|
@ -1087,7 +1088,7 @@ class Feed
|
|||
*/
|
||||
private static function noteEntry(DOMDocument $doc, array $item, array $owner): DOMElement
|
||||
{
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
Logger::info('Feed entry author does not match feed owner', ['owner' => $owner['url'], 'author' => $item['author-link']]);
|
||||
}
|
||||
|
||||
|
@ -1151,7 +1152,7 @@ class Feed
|
|||
{
|
||||
$mentioned = [];
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
|
||||
|
||||
$thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner['uid'], 'uri' => $item['thr-parent']]);
|
||||
|
|
|
@ -391,7 +391,7 @@ class OStatus
|
|||
$header['network'] = Protocol::OSTATUS;
|
||||
$header['wall'] = 0;
|
||||
$header['origin'] = 0;
|
||||
$header['gravity'] = GRAVITY_COMMENT;
|
||||
$header['gravity'] = Item::GRAVITY_COMMENT;
|
||||
|
||||
if (!is_object($doc->firstChild) || empty($doc->firstChild->tagName)) {
|
||||
return false;
|
||||
|
@ -499,7 +499,7 @@ class OStatus
|
|||
|
||||
$item['verb'] = Activity::LIKE;
|
||||
$item['thr-parent'] = $orig_uri;
|
||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||
$item['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
}
|
||||
|
||||
|
@ -714,7 +714,7 @@ class OStatus
|
|||
}
|
||||
} else {
|
||||
$item['thr-parent'] = $item['uri'];
|
||||
$item['gravity'] = GRAVITY_PARENT;
|
||||
$item['gravity'] = Item::GRAVITY_PARENT;
|
||||
}
|
||||
|
||||
self::$itemlist[] = $item;
|
||||
|
@ -1359,7 +1359,7 @@ class OStatus
|
|||
*/
|
||||
private static function likeEntry(DOMDocument $doc, array $item, array $owner, bool $toplevel): DOMElement
|
||||
{
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
Logger::info('OStatus entry is from author ' . $owner['url'] . ' - not from ' . $item['author-link'] . '. Quitting.');
|
||||
}
|
||||
|
||||
|
@ -1509,7 +1509,7 @@ class OStatus
|
|||
*/
|
||||
private static function noteEntry(DOMDocument $doc, array $item, array $owner, bool $toplevel): DOMElement
|
||||
{
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
Logger::info('OStatus entry is from author ' . $owner['url'] . ' - not from ' . $item['author-link'] . '. Quitting.');
|
||||
}
|
||||
|
||||
|
@ -1639,7 +1639,7 @@ class OStatus
|
|||
{
|
||||
$mentioned = [];
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
|
||||
|
||||
$thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner['uid'], 'uri' => $item['thr-parent']]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue