mirror of
https://github.com/friendica/friendica
synced 2025-04-24 00:30:11 +00:00
The desktop notifications have been reworked
This commit is contained in:
parent
632d1024f7
commit
42de5c77d0
7 changed files with 476 additions and 290 deletions
|
@ -182,7 +182,7 @@ class Notification extends BaseModel
|
|||
return $message;
|
||||
}
|
||||
|
||||
$contact = Contact::getById($notification['actor-id']);
|
||||
$causer = $contact = Contact::getById($notification['actor-id'], ['id', 'name', 'url']);
|
||||
if (empty($contact)) {
|
||||
Logger::info('Contact not found', ['contact' => $notification['actor-id']]);
|
||||
return $message;
|
||||
|
@ -193,7 +193,7 @@ class Notification extends BaseModel
|
|||
$announce = Verb::getID(Activity::ANNOUNCE);
|
||||
$post = Verb::getID(Activity::POST);
|
||||
|
||||
if (in_array($notification['type'], [Post\UserNotification::NOTIF_THREAD_COMMENT, Post\UserNotification::NOTIF_COMMENT_PARTICIPATION])) {
|
||||
if (in_array($notification['type'], [Post\UserNotification::NOTIF_THREAD_COMMENT, Post\UserNotification::NOTIF_COMMENT_PARTICIPATION, Post\UserNotification::NOTIF_EXPLICIT_TAGGED])) {
|
||||
$item = Post::selectFirst([], ['uri-id' => $notification['parent-uri-id'], 'uid' => [0, $notification['uid']]]);
|
||||
if (empty($item)) {
|
||||
Logger::info('Parent post not found', ['uri-id' => $notification['parent-uri-id']]);
|
||||
|
@ -215,6 +215,14 @@ class Notification extends BaseModel
|
|||
}
|
||||
}
|
||||
|
||||
if (($notification['type'] == Post\UserNotification::NOTIF_SHARED) && !empty($item['causer-id'])) {
|
||||
$causer = Contact::getById($item['causer-id'], ['id', 'name', 'url']);
|
||||
if (empty($contact)) {
|
||||
Logger::info('Causer not found', ['causer' => $item['causer-id']]);
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
||||
$link = DI::baseUrl() . '/display/' . urlencode($item['guid']);
|
||||
|
||||
$content = Plaintext::getPost($item, 70);
|
||||
|
@ -288,7 +296,11 @@ class Notification extends BaseModel
|
|||
break;
|
||||
|
||||
case Post\UserNotification::NOTIF_SHARED:
|
||||
if ($title != '') {
|
||||
if (($causer['id'] != $contact['id']) && ($title != '')) {
|
||||
$msg = $l10n->t('%1$s shared the post %2$s from %3$s');
|
||||
} elseif ($causer['id'] != $contact['id']) {
|
||||
$msg = $l10n->t('%1$s shared a post from %3$s');
|
||||
} elseif ($title != '') {
|
||||
$msg = $l10n->t('%1$s shared the post %2$s');
|
||||
} else {
|
||||
$msg = $l10n->t('%1$s shared a post');
|
||||
|
@ -300,15 +312,16 @@ class Notification extends BaseModel
|
|||
|
||||
if (!empty($msg)) {
|
||||
// Name of the notification's causer
|
||||
$message['causer'] = $contact['name'];
|
||||
$message['causer'] = $causer['name'];
|
||||
// Format for the "ping" mechanism
|
||||
$message['notification'] = sprintf($msg, '{0}', $title);
|
||||
$message['notification'] = sprintf($msg, '{0}', $title, $contact['name']);
|
||||
// Plain text for the web push api
|
||||
$message['plain'] = sprintf($msg, $contact['name'], $title);
|
||||
$message['plain'] = sprintf($msg, $causer['name'], $title, $contact['name']);
|
||||
// Rich text for other purposes
|
||||
$message['rich'] = sprintf($msg,
|
||||
'[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]',
|
||||
'[url=' . $link . ']' . $title . '[/url]');
|
||||
'[url=' . $causer['url'] . ']' . $causer['name'] . '[/url]',
|
||||
'[url=' . $link . ']' . $title . '[/url]',
|
||||
'[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]');
|
||||
}
|
||||
|
||||
return $message;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue