mirror of
https://github.com/friendica/friendica
synced 2025-04-26 19:10:11 +00:00
Issue 13535: Handle Firefish chat messages
This commit is contained in:
parent
e99fcfddb5
commit
3f9783f288
2 changed files with 32 additions and 5 deletions
|
@ -429,6 +429,10 @@ class Receiver
|
|||
$object_data['directmessage'] = true;
|
||||
} else {
|
||||
$object_data['directmessage'] = JsonLD::fetchElement($activity, 'litepub:directMessage');
|
||||
|
||||
if (!empty(JsonLD::fetchElement($activity['as:object'], 'misskey:_misskey_talk'))) {
|
||||
$object_data = self::setChatData($object_data, $receivers);
|
||||
}
|
||||
}
|
||||
} elseif (in_array($type, array_merge(self::ACTIVITY_TYPES, ['as:Announce', 'as:Follow'])) && in_array($object_type, self::CONTENT_TYPES)) {
|
||||
// Create a mostly empty array out of the activity data (instead of the object).
|
||||
|
@ -507,6 +511,26 @@ class Receiver
|
|||
return $object_data;
|
||||
}
|
||||
|
||||
private static function setChatData(array $object_data, array $receivers): array
|
||||
{
|
||||
if (count($receivers) != 1) {
|
||||
return $object_data;
|
||||
}
|
||||
|
||||
$user = User::getById(array_key_first($receivers), ['language']);
|
||||
$l10n = DI::l10n()->withLang($user['language']);
|
||||
$object_data['name'] = $l10n->t('Chat');
|
||||
|
||||
$mail = DBA::selectFirst('mail', ['uri'], ['uid' => array_key_first($receivers), 'title' => $object_data['name']], ['order' => ['id' => true]]);
|
||||
if (!empty($mail['uri'])) {
|
||||
$object_data['reply-to-id'] = $mail['uri'];
|
||||
}
|
||||
|
||||
$object_data['directmessage'] = true;
|
||||
Logger::debug('Got Misskey Chat');
|
||||
return $object_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the first user id from the receiver array
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue