class Engagement
{
- const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'tag', 'network', 'platform', 'visibility', 'language'];
+ const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language'];
/**
* Store engagement data from an item array
if ($item['author-contact-type'] == Contact::TYPE_COMMUNITY) {
$body .= ' group_' . $item['author-nick'] . ' group_' . $item['author-addr'];
+ } elseif ($item['author-contact-type'] == Contact::TYPE_RELAY) {
+ $body .= ' application_' . $item['author-nick'] . ' application_' . $item['author-addr'];
} elseif (in_array($item['author-contact-type'], [Contact::TYPE_PERSON, Contact::TYPE_NEWS, Contact::TYPE_ORGANISATION])) {
$body .= ' from_' . $item['author-nick'] . ' from_' . $item['author-addr'];
}
}
}
+ $body = self::addResharers($body, $item['uri-id']);
+
foreach ($receivers as $receiver) {
$contact = Contact::getByURL($receiver, false, ['nick', 'addr', 'contact-type']);
if (empty($contact)) {
return BBCode::toSearchText($body, $item['uri-id']);
}
+ private static function addResharers(string $text, int $uri_id): string
+ {
+ $result = Post::selectPosts(['author-addr', 'author-nick', 'author-contact-type'],
+ ['thr-parent-id' => $uri_id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE, 'author-contact-type' => [Contact::TYPE_RELAY, Contact::TYPE_COMMUNITY]]);
+ while ($reshare = Post::fetch($result)) {
+ switch ($reshare['author-contact-type']) {
+ case Contact::TYPE_RELAY:
+ $prefix = ' application_';
+ break;
+ case Contact::TYPE_COMMUNITY:
+ $prefix = ' group_';
+ break;
+ }
+ $nick = $prefix . $reshare['author-nick'];
+ $addr = $prefix . $reshare['author-addr'];
+
+ if (stripos($text, $addr) === false) {
+ $text .= $nick . $addr;
+ }
+ }
+ DBA::close($result);
+
+ return $text;
+ }
+
private static function getMediaType(int $uri_id): int
{
$media = Post\Media::getByURIId($uri_id);