*
* @return string with replaced emojis
*/
- private static function replaceEmojis($body, array $emojis)
+ private static function replaceEmojis(int $uri_id, $body, array $emojis)
{
$body = strtr($body,
array_combine(
)
);
+ // We store the emoji here to be able to avoid storing it in the media
+ foreach ($emojis as $emoji) {
+ Post\Link::getByLink($uri_id, $emoji['href']);
+ }
return $body;
}
*
* @param array $activity Activity array
* @param array $item
- *
+ *
* @return int event id
* @throws \Exception
*/
$event['finish'] = $activity['end-time'];
$event['nofinish'] = empty($event['finish']);
$event['location'] = $activity['location'];
- $event['adjust'] = $activity['adjust'] ?? true;
$event['cid'] = $item['contact-id'];
$event['uid'] = $item['uid'];
$event['uri'] = $item['uri'];
}
if (!empty($activity['emojis'])) {
- $content = self::replaceEmojis($content, $activity['emojis']);
+ $content = self::replaceEmojis($item['uri-id'], $content, $activity['emojis']);
}
$content = self::addMentionLinks($content, $activity['tags']);
$cid = Contact::getIdForURL($activity['actor'], $uid);
if (!empty($cid)) {
self::switchContact($cid);
- DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
+ Contact::update(['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
}
$item = ['author-id' => Contact::getIdForURL($activity['actor']),
}
if (empty($contact)) {
- DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
+ Contact::update(['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
}
Logger::notice('Follow user ' . $uid . ' from contact ' . $cid . ' with id ' . $activity['id']);
}
$condition = ['id' => $cid];
- DBA::update('contact', $fields, $condition);
+ Contact::update($fields, $condition);
Logger::info('Accept contact request', ['contact' => $cid, 'user' => $uid]);
}
self::switchContact($cid);
- if (DBA::exists('contact', ['id' => $cid, 'rel' => Contact::SHARING])) {
+ $contact = Contact::getById($cid, ['rel']);
+ if ($contact['rel'] == Contact::SHARING) {
Contact::remove($cid);
Logger::info('Rejected contact request - contact removed', ['contact' => $cid, 'user' => $uid]);
+ } elseif ($contact['rel'] == Contact::FRIEND) {
+ Contact::update(['rel' => Contact::FOLLOWER], ['id' => $cid]);
} else {
Logger::info('Rejected contact request', ['contact' => $cid, 'user' => $uid]);
}
return;
}
- Contact::removeFollower($owner, $contact);
+ Contact::removeFollower($contact);
Logger::info('Undo following request', ['contact' => $cid, 'user' => $uid]);
}