The notifications parameters are now simplified

This commit is contained in:
Michael 2020-11-25 19:56:39 +00:00
parent 32f70abf9a
commit 818c064c0a
17 changed files with 143 additions and 187 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2020.12-dev (Red Hot Poker) -- Friendica 2020.12-dev (Red Hot Poker)
-- DB_UPDATE_VERSION 1379 -- DB_UPDATE_VERSION 1380
-- ------------------------------------------ -- ------------------------------------------

View File

@ -26,6 +26,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\ItemContent; use Friendica\Model\ItemContent;
use Friendica\Model\Notify; use Friendica\Model\Notify;
@ -37,10 +38,10 @@ use Friendica\Protocol\Activity;
* Creates a notification entry and possibly sends a mail * Creates a notification entry and possibly sends a mail
* *
* @param array $params Array with the elements: * @param array $params Array with the elements:
* uid, item, parent, type, otype, verb, event, * type, event, otype, activity, verb, uid, cid, origin_cid, item, link,
* link, subject, body, to_name, to_email, source_name, * source_name, source_mail, source_nick, source_link, source_photo,
* source_link, activity, preamble, notify_flags, * show_in_notification_page
* language, show_in_notification_page *
* @return bool * @return bool
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
@ -55,7 +56,7 @@ function notification($params)
} }
// Ensure that the important fields are set at any time // Ensure that the important fields are set at any time
$fields = ['notify-flags', 'language', 'username', 'email']; $fields = ['nickname', 'page-flags', 'notify-flags', 'language', 'username', 'email'];
$user = DBA::selectFirst('user', $fields, ['uid' => $params['uid']]); $user = DBA::selectFirst('user', $fields, ['uid' => $params['uid']]);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
@ -63,14 +64,39 @@ function notification($params)
return false; return false;
} }
$params['notify_flags'] = ($params['notify_flags'] ?? '') ?: $user['notify-flags']; // There is no need to create notifications for forum accounts
$params['language'] = ($params['language'] ?? '') ?: $user['language']; if (in_array($user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
$params['to_name'] = ($params['to_name'] ?? '') ?: $user['username']; return false;
$params['to_email'] = ($params['to_email'] ?? '') ?: $user['email']; }
$nickname = $user['nickname'];
$params['notify_flags'] = $user['notify-flags'];
$params['language'] = $user['language'];
$params['to_name'] = $user['username'];
$params['to_email'] = $user['email'];
// from here on everything is in the recipients language // from here on everything is in the recipients language
$l10n = DI::l10n()->withLang($params['language']); $l10n = DI::l10n()->withLang($params['language']);
if (!empty($params['cid'])) {
$contact = Contact::getById($params['cid'], ['url', 'name', 'photo']);
if (DBA::isResult($contact)) {
$params['source_link'] = $contact['url'];
$params['source_name'] = $contact['name'];
$params['source_photo'] = $contact['photo'];
}
}
if (!empty($params['origin_cid'])) {
$contact = Contact::getById($params['origin_cid'], ['url', 'name', 'photo']);
if (DBA::isResult($contact)) {
$params['origin_link'] = $contact['url'];
$params['origin_name'] = $contact['name'];
$params['origin_photo'] = $contact['photo'];
}
}
$siteurl = DI::baseUrl()->get(true); $siteurl = DI::baseUrl()->get(true);
$sitename = DI::config()->get('config', 'sitename'); $sitename = DI::config()->get('config', 'sitename');
@ -79,14 +105,6 @@ function notification($params)
$hostname = substr($hostname, 0, strpos($hostname, ':')); $hostname = substr($hostname, 0, strpos($hostname, ':'));
} }
$user = User::getById($params['uid'], ['nickname', 'page-flags']);
// There is no need to create notifications for forum accounts
if (!DBA::isResult($user) || in_array($user["page-flags"], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
return false;
}
$nickname = $user["nickname"];
// Creates a new email builder for the notification email // Creates a new email builder for the notification email
$emailBuilder = DI::emailer()->newNotifyMail(); $emailBuilder = DI::emailer()->newNotifyMail();
@ -97,36 +115,13 @@ function notification($params)
$emailBuilder->setHeader('X-Friendica-Account', '<' . $nickname . '@' . $hostname . '>'); $emailBuilder->setHeader('X-Friendica-Account', '<' . $nickname . '@' . $hostname . '>');
if (array_key_exists('item', $params)) { $title = $params['item']['title'] ?? '';
$title = $params['item']['title']; $body = $params['item']['body'] ?? '';
$body = $params['item']['body'];
} else {
$title = $body = '';
}
if (isset($params['item']['id'])) { $item_id = $params['item']['id'] ?? 0;
$item_id = $params['item']['id']; $uri_id = $params['item']['uri-id'] ?? 0;
} else { $parent_id = $params['item']['parent'] ?? 0;
$item_id = 0; $parent_uri_id = $params['item']['parent-uri-id'] ?? 0;
}
if (isset($params['item']['uri-id'])) {
$uri_id = $params['item']['uri-id'];
} else {
$uri_id = 0;
}
if (isset($params['parent'])) {
$parent_id = $params['parent'];
} else {
$parent_id = 0;
}
if (isset($params['item']['parent-uri-id'])) {
$parent_uri_id = $params['item']['parent-uri-id'];
} else {
$parent_uri_id = 0;
}
$epreamble = ''; $epreamble = '';
$preamble = ''; $preamble = '';
@ -137,8 +132,7 @@ function notification($params)
$itemlink = ''; $itemlink = '';
if ($params['type'] == Notify\Type::MAIL) { if ($params['type'] == Notify\Type::MAIL) {
$itemlink = $siteurl.'/message/'.$params['item']['id']; $itemlink = $params['link'];
$params["link"] = $itemlink;
$subject = $l10n->t('%s New mail received at %s', $subjectPrefix, $sitename); $subject = $l10n->t('%s New mail received at %s', $subjectPrefix, $sitename);
@ -146,8 +140,11 @@ function notification($params)
$epreamble = $l10n->t('%1$s sent you %2$s.', '[url='.$params['source_link'].']'.$params['source_name'].'[/url]', '[url=' . $itemlink . ']' . $l10n->t('a private message').'[/url]'); $epreamble = $l10n->t('%1$s sent you %2$s.', '[url='.$params['source_link'].']'.$params['source_name'].'[/url]', '[url=' . $itemlink . ']' . $l10n->t('a private message').'[/url]');
$sitelink = $l10n->t('Please visit %s to view and/or reply to your private messages.'); $sitelink = $l10n->t('Please visit %s to view and/or reply to your private messages.');
$tsitelink = sprintf($sitelink, $siteurl.'/message/'.$params['item']['id']); $tsitelink = sprintf($sitelink, $itemlink);
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'/message/'.$params['item']['id'].'">'.$sitename.'</a>'); $hsitelink = sprintf($sitelink, '<a href="' . $itemlink . '">' . $sitename . '</a>');
// Mail notifications aren't using the "notify" table entry
$show_in_notification_page = false;
} }
if ($params['type'] == Notify\Type::COMMENT || $params['type'] == Notify\Type::TAG_SELF) { if ($params['type'] == Notify\Type::COMMENT || $params['type'] == Notify\Type::TAG_SELF) {
@ -493,10 +490,10 @@ function notification($params)
if (!empty($uri_id)) { if (!empty($uri_id)) {
$fields['uri-id'] = $uri_id; $fields['uri-id'] = $uri_id;
} }
if (!empty($item_id)) { if (!empty($parent_id)) {
$fields['parent'] = $parent_id; $fields['parent'] = $parent_id;
} }
if (!empty($item_id)) { if (!empty($parent_uri_id)) {
$fields['parent-uri-id'] = $parent_uri_id; $fields['parent-uri-id'] = $parent_uri_id;
} }
$notification = DI::notify()->insert($fields); $notification = DI::notify()->insert($fields);
@ -628,14 +625,11 @@ function check_item_notification($itemid, $uid, $notification_type) {
// Generate the notification array // Generate the notification array
$params = []; $params = [];
$params['otype'] = Notify\ObjectType::ITEM;
$params['uid'] = $uid; $params['uid'] = $uid;
$params['origin_cid'] = $params['cid'] = $item['author-id'];
$params['item'] = $item; $params['item'] = $item;
$params['parent'] = $item['parent'];
$params['link'] = DI::baseUrl() . '/display/' . urlencode($item['guid']); $params['link'] = DI::baseUrl() . '/display/' . urlencode($item['guid']);
$params['otype'] = 'item';
$params['origin_name'] = $params['source_name'] = $item['author-name'];
$params['origin_link'] = $params['source_link'] = $item['author-link'];
$params['origin_photo'] = $params['source_photo'] = $item['author-avatar'];
// Set the activity flags // Set the activity flags
$params['activity']['explicit_tagged'] = ($notification_type & UserItem::NOTIF_EXPLICIT_TAGGED); $params['activity']['explicit_tagged'] = ($notification_type & UserItem::NOTIF_EXPLICIT_TAGGED);
@ -663,9 +657,7 @@ function check_item_notification($itemid, $uid, $notification_type) {
return false; return false;
} }
$params['origin_name'] = $parent_item['author-name']; $params['origin_cid'] = $parent_item['author-id'];
$params['origin_link'] = $parent_item['author-link'];
$params['origin_photo'] = $parent_item['author-avatar'];
$params['item'] = $parent_item; $params['item'] = $parent_item;
} }
} }

View File

@ -40,6 +40,7 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Notify;
use Friendica\Model\Notify\Type; use Friendica\Model\Notify\Type;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
@ -542,18 +543,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
if ($combined['notify-flags'] & Type::CONFIRM) { if ($combined['notify-flags'] & Type::CONFIRM) {
$mutual = ($new_relation == Contact::FRIEND); $mutual = ($new_relation == Contact::FRIEND);
notification([ notification([
'type' => Type::CONFIRM, 'type' => Type::CONFIRM,
'notify_flags' => $combined['notify-flags'], 'otype' => Notify\ObjectType::INTRO,
'language' => $combined['language'], 'verb' => ($mutual ? Activity::FRIEND : Activity::FOLLOW),
'to_name' => $combined['username'], 'uid' => $combined['uid'],
'to_email' => $combined['email'], 'cid' => $combined['id'],
'uid' => $combined['uid'], 'link' => DI::baseUrl() . '/contact/' . $dfrn_record,
'link' => DI::baseUrl() . '/contact/' . $dfrn_record,
'source_name' => ((strlen(stripslashes($combined['name']))) ? stripslashes($combined['name']) : DI::l10n()->t('[Name Withheld]')),
'source_link' => $combined['url'],
'source_photo' => $combined['photo'],
'verb' => ($mutual ? Activity::FRIEND : Activity::FOLLOW),
'otype' => 'intro'
]); ]);
} }
} }

View File

@ -35,6 +35,7 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Notify;
use Friendica\Model\Notify\Type; use Friendica\Model\Notify\Type;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\User; use Friendica\Model\User;
@ -559,18 +560,12 @@ function dfrn_request_content(App $a)
if (!$auto_confirm) { if (!$auto_confirm) {
notification([ notification([
'type' => Type::INTRO, 'type' => Type::INTRO,
'notify_flags' => $r[0]['notify-flags'], 'otype' => Notify\ObjectType::INTRO,
'language' => $r[0]['language'], 'verb' => Activity::REQ_FRIEND,
'to_name' => $r[0]['username'], 'uid' => $r[0]['uid'],
'to_email' => $r[0]['email'], 'cid' => $r[0]['id'],
'uid' => $r[0]['uid'], 'link' => DI::baseUrl() . '/notifications/intros',
'link' => DI::baseUrl() . '/notifications/intros',
'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : DI::l10n()->t('[Name Withheld]')),
'source_link' => $r[0]['url'],
'source_photo' => $r[0]['photo'],
'verb' => Activity::REQ_FRIEND,
'otype' => 'intro'
]); ]);
} }

View File

@ -187,7 +187,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
if ($update) { if ($update) {
$item_id = $_REQUEST['item_id']; $item_id = $_REQUEST['item_id'];
$item = Item::selectFirst(['uid', 'parent', 'parent-uri'], ['id' => $item_id]); $item = Item::selectFirst(['uid', 'parent', 'parent-uri', 'parent-uri-id'], ['id' => $item_id]);
if ($item['uid'] != 0) { if ($item['uid'] != 0) {
$a->profile = ['uid' => intval($item['uid'])]; $a->profile = ['uid' => intval($item['uid'])];
} else { } else {
@ -201,7 +201,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
if ($a->argc == 2) { if ($a->argc == 2) {
$item_parent = 0; $item_parent = 0;
$fields = ['id', 'parent', 'parent-uri', 'uid']; $fields = ['id', 'parent', 'parent-uri', 'parent-uri-id', 'uid'];
if (local_user()) { if (local_user()) {
$condition = ['guid' => $a->argv[1], 'uid' => local_user()]; $condition = ['guid' => $a->argv[1], 'uid' => local_user()];
@ -239,7 +239,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
} }
if (!DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) { if (!DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) {
DBA::update('notify', ['seen' => true], ['parent' => $item['parent'], 'uid' => local_user()]); DBA::update('notify', ['seen' => true], ['parent-uri-id' => $item['parent-uri-id'], 'uid' => local_user()]);
} }
// We are displaying an "alternate" link if that post was public. See issue 2864 // We are displaying an "alternate" link if that post was public. See issue 2864

View File

@ -45,6 +45,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Conversation; use Friendica\Model\Conversation;
use Friendica\Model\FileTag; use Friendica\Model\FileTag;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Notify;
use Friendica\Model\Notify\Type; use Friendica\Model\Notify\Type;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use Friendica\Model\Post; use Friendica\Model\Post;
@ -756,37 +757,23 @@ function item_post(App $a) {
if ($contact_record != $author) { if ($contact_record != $author) {
if ($toplevel_item_id) { if ($toplevel_item_id) {
notification([ notification([
'type' => Type::COMMENT, 'type' => Type::COMMENT,
'notify_flags' => $user['notify-flags'], 'otype' => Notify\ObjectType::ITEM,
'language' => $user['language'], 'verb' => Activity::POST,
'to_name' => $user['username'], 'uid' => $user['uid'],
'to_email' => $user['email'], 'cid' => $datarray['author-id'],
'uid' => $user['uid'], 'item' => $datarray,
'item' => $datarray, 'link' => DI::baseUrl() . '/display/' . urlencode($datarray['guid']),
'link' => DI::baseUrl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
'verb' => Activity::POST,
'otype' => 'item',
'parent' => $toplevel_item_id,
'parent_uri' => $toplevel_item['uri']
]); ]);
} elseif (empty($forum_contact)) { } elseif (empty($forum_contact)) {
notification([ notification([
'type' => Type::WALL, 'type' => Type::WALL,
'notify_flags' => $user['notify-flags'], 'otype' => Notify\ObjectType::ITEM,
'language' => $user['language'], 'verb' => Activity::POST,
'to_name' => $user['username'], 'uid' => $user['uid'],
'to_email' => $user['email'], 'cid' => $datarray['author-id'],
'uid' => $user['uid'], 'item' => $datarray,
'item' => $datarray, 'link' => DI::baseUrl() . '/display/' . urlencode($datarray['guid']),
'link' => DI::baseUrl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
'verb' => Activity::POST,
'otype' => 'item'
]); ]);
} }
} }

View File

@ -282,7 +282,6 @@ function message_content(App $a)
$messages = DBA::toArray($messages_stmt); $messages = DBA::toArray($messages_stmt);
DBA::update('mail', ['seen' => 1], ['parent-uri' => $message['parent-uri'], 'uid' => local_user()]); DBA::update('mail', ['seen' => 1], ['parent-uri' => $message['parent-uri'], 'uid' => local_user()]);
DBA::update('notify', ['seen' => 1], ['type' => Type::MAIL, 'parent' => $message['id'], 'uid' => local_user()]);
} else { } else {
$messages = false; $messages = false;
} }

View File

@ -1217,6 +1217,7 @@ class Worker
// Don't fork from frontend tasks by default // Don't fork from frontend tasks by default
$dont_fork = DI::config()->get("system", "worker_dont_fork", false) || !DI::mode()->isBackend(); $dont_fork = DI::config()->get("system", "worker_dont_fork", false) || !DI::mode()->isBackend();
$created = DateTimeFormat::utcNow(); $created = DateTimeFormat::utcNow();
$delayed = DBA::NULL_DATETIME;
$force_priority = false; $force_priority = false;
$run_parameter = array_shift($args); $run_parameter = array_shift($args);
@ -1224,6 +1225,9 @@ class Worker
if (is_int($run_parameter)) { if (is_int($run_parameter)) {
$priority = $run_parameter; $priority = $run_parameter;
} elseif (is_array($run_parameter)) { } elseif (is_array($run_parameter)) {
if (isset($run_parameter['delayed'])) {
$delayed = $run_parameter['execute'];
}
if (isset($run_parameter['priority'])) { if (isset($run_parameter['priority'])) {
$priority = $run_parameter['priority']; $priority = $run_parameter['priority'];
} }
@ -1248,7 +1252,8 @@ class Worker
} }
if (!$found) { if (!$found) {
$added = DBA::insert('workerqueue', ['parameter' => $parameters, 'created' => $created, 'priority' => $priority]); $added = DBA::insert('workerqueue', ['parameter' => $parameters, 'created' => $created,
'priority' => $priority, 'next_try' => $delayed]);
if (!$added) { if (!$added) {
return false; return false;
} }

View File

@ -2426,18 +2426,12 @@ class Contact
in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL])) { in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL])) {
notification([ notification([
'type' => Type::INTRO, 'type' => Type::INTRO,
'notify_flags' => $user['notify-flags'], 'otype' => Notify\ObjectType::INTRO,
'language' => $user['language'], 'verb' => ($sharing ? Activity::FRIEND : Activity::FOLLOW),
'to_name' => $user['username'], 'uid' => $user['uid'],
'to_email' => $user['email'], 'cid' => $contact_record['id'],
'uid' => $user['uid'], 'link' => DI::baseUrl() . '/notifications/intros',
'link' => DI::baseUrl() . '/notifications/intros',
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : DI::l10n()->t('[Name Withheld]')),
'source_link' => $contact_record['url'],
'source_photo' => $contact_record['photo'],
'verb' => ($sharing ? Activity::FRIEND : Activity::FOLLOW),
'otype' => 'intro'
]); ]);
} }
} elseif (DBA::isResult($user) && in_array($user['page-flags'], [User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE, User::PAGE_FLAGS_COMMUNITY])) { } elseif (DBA::isResult($user) && in_array($user['page-flags'], [User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE, User::PAGE_FLAGS_COMMUNITY])) {

View File

@ -181,19 +181,13 @@ class FContact
DBA::insert('intro', $fields); DBA::insert('intro', $fields);
notification([ notification([
'type' => Type::SUGGEST, 'type' => Type::SUGGEST,
'notify_flags' => $owner['notify-flags'], 'otype' => Notify\ObjectType::INTRO,
'language' => $owner['language'], 'verb' => Activity::REQ_FRIEND,
'to_name' => $owner['name'], 'uid' => $owner['uid'],
'to_email' => $owner['email'], 'cid' => $from_contact['uid'],
'uid' => $owner['uid'], 'item' => $suggest,
'item' => $suggest, 'link' => DI::baseUrl().'/notifications/intros',
'link' => DI::baseUrl().'/notifications/intros',
'source_name' => $from_contact['name'],
'source_link' => $from_contact['url'],
'source_photo' => $from_contact['photo'],
'verb' => Activity::REQ_FRIEND,
'otype' => 'intro'
]); ]);
return true; return true;

View File

@ -1065,9 +1065,6 @@ class Item
// "Deleting" global items just means hiding them // "Deleting" global items just means hiding them
if ($item['uid'] == 0) { if ($item['uid'] == 0) {
DBA::update('user-item', ['hidden' => true], ['iid' => $item['id'], 'uid' => $uid], true); DBA::update('user-item', ['hidden' => true], ['iid' => $item['id'], 'uid' => $uid], true);
// Delete notifications
DBA::delete('notify', ['iid' => $item['id'], 'uid' => $uid]);
} elseif ($item['uid'] == $uid) { } elseif ($item['uid'] == $uid) {
self::markForDeletionById($item['id'], PRIORITY_HIGH); self::markForDeletionById($item['id'], PRIORITY_HIGH);
} else { } else {
@ -1155,9 +1152,6 @@ class Item
} }
} }
// Delete notifications
DBA::delete('notify', ['iid' => $item['id'], 'uid' => $item['uid']]);
// Set the item to "deleted" // Set the item to "deleted"
$item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()]; $item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
DBA::update('item', $item_fields, ['id' => $item['id']]); DBA::update('item', $item_fields, ['id' => $item['id']]);
@ -1171,9 +1165,6 @@ class Item
Post\DeliveryData::delete($item['uri-id']); Post\DeliveryData::delete($item['uri-id']);
if (!empty($item['icid']) && !self::exists(['icid' => $item['icid'], 'deleted' => false])) {
DBA::delete('item-content', ['id' => $item['icid']], ['cascade' => false]);
}
// When the permission set will be used in photo and events as well, // When the permission set will be used in photo and events as well,
// this query here needs to be extended. // this query here needs to be extended.
// @todo Currently deactivated. We need the permission set in the deletion process. // @todo Currently deactivated. We need the permission set in the deletion process.

View File

@ -84,19 +84,12 @@ class Mail
// send notifications. // send notifications.
$notif_params = [ $notif_params = [
'type' => Type::MAIL, 'type' => Type::MAIL,
'notify_flags' => $user['notify-flags'], 'otype' => Notify\ObjectType::MAIL,
'language' => $user['language'], 'verb' => Activity::POST,
'to_name' => $user['username'], 'uid' => $user['uid'],
'to_email' => $user['email'], 'cid' => $msg['contact-id'],
'uid' => $user['uid'], 'link' => DI::baseUrl() . '/message/' . $msg['id'],
'item' => $msg,
'parent' => $msg['id'],
'source_name' => $msg['from-name'],
'source_link' => $msg['from-url'],
'source_photo' => $msg['from-photo'],
'verb' => Activity::POST,
'otype' => 'mail'
]; ];
notification($notif_params); notification($notif_params);

View File

@ -367,15 +367,13 @@ class Register extends BaseModule
\notification([ \notification([
'type' => Model\Notify\Type::SYSTEM, 'type' => Model\Notify\Type::SYSTEM,
'event' => 'SYSTEM_REGISTER_REQUEST', 'event' => 'SYSTEM_REGISTER_REQUEST',
'uid' => $admin['uid'],
'link' => $base_url . '/admin/users/',
'source_name' => $user['username'], 'source_name' => $user['username'],
'source_mail' => $user['email'], 'source_mail' => $user['email'],
'source_nick' => $user['nickname'], 'source_nick' => $user['nickname'],
'source_link' => $base_url . '/admin/users/', 'source_link' => $base_url . '/admin/users/',
'link' => $base_url . '/admin/users/',
'source_photo' => $base_url . '/photo/avatar/' . $user['uid'] . '.jpg', 'source_photo' => $base_url . '/photo/avatar/' . $user['uid'] . '.jpg',
'to_email' => $admin['email'],
'uid' => $admin['uid'],
'language' => ($admin['language'] ?? '') ?: 'en',
'show_in_notification_page' => false 'show_in_notification_page' => false
]); ]);
} }

View File

@ -37,6 +37,7 @@ use Friendica\Model\FContact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\ItemURI; use Friendica\Model\ItemURI;
use Friendica\Model\Mail; use Friendica\Model\Mail;
use Friendica\Model\Notify;
use Friendica\Model\Notify\Type; use Friendica\Model\Notify\Type;
use Friendica\Model\PermissionSet; use Friendica\Model\PermissionSet;
use Friendica\Model\Post; use Friendica\Model\Post;
@ -2005,7 +2006,7 @@ class DFRN
} }
if ($Blink && Strings::compareLink($Blink, DI::baseUrl() . "/profile/" . $importer["nickname"])) { if ($Blink && Strings::compareLink($Blink, DI::baseUrl() . "/profile/" . $importer["nickname"])) {
$author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]); $author = DBA::selectFirst('contact', ['id', 'name', 'thumb', 'url'], ['id' => $item['author-id']]);
$parent = Item::selectFirst(['id'], ['uri' => $item['thr-parent'], 'uid' => $importer["importer_uid"]]); $parent = Item::selectFirst(['id'], ['uri' => $item['thr-parent'], 'uid' => $importer["importer_uid"]]);
$item['parent'] = $parent['id']; $item['parent'] = $parent['id'];
@ -2013,21 +2014,15 @@ class DFRN
// send a notification // send a notification
notification( notification(
[ [
"type" => Type::POKE, "type" => Type::POKE,
"notify_flags" => $importer["notify-flags"], "otype" => Notify\ObjectType::PERSON,
"language" => $importer["language"], "activity" => $verb,
"to_name" => $importer["username"], "verb" => $item["verb"],
"to_email" => $importer["email"], "uid" => $importer["importer_uid"],
"uid" => $importer["importer_uid"], "cid" => $author["id"],
"item" => $item, "item" => $item,
"link" => DI::baseUrl()."/display/".urlencode($item['guid']), "link" => DI::baseUrl() . "/display/" . urlencode($item['guid']),
"source_name" => $author["name"], ]
"source_link" => $author["url"],
"source_photo" => $author["thumb"],
"verb" => $item["verb"],
"otype" => "person",
"activity" => $verb,
"parent" => $item['parent']]
); );
} }
} }

View File

@ -55,7 +55,7 @@
use Friendica\Database\DBA; use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1379); define('DB_UPDATE_VERSION', 1380);
} }
return [ return [

View File

@ -19,6 +19,8 @@
* *
*/ */
use Friendica\Model\Notify;
return [ return [
// Empty these tables // Empty these tables
'cache', 'cache',
@ -317,7 +319,7 @@ return [
'iid' => 4, 'iid' => 4,
'seen' => 0, 'seen' => 0,
'verb' => '', 'verb' => '',
'otype' => 'item', 'otype' => Notify\ObjectType::ITEM,
'name_cache' => 'Reply to', 'name_cache' => 'Reply to',
'msg_cache' => 'A test reply from an item', 'msg_cache' => 'A test reply from an item',
], ],

View File

@ -50,6 +50,7 @@ use Friendica\Database\DBStructure;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Notify;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Model\Storage; use Friendica\Model\Storage;
@ -856,3 +857,18 @@ function pre_update_1377()
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1380()
{
if (!DBA::e("UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`iid` SET `notify`.`uri-id` = `item`.`uri-id` WHERE `notify`.`uri-id` IS NULL AND `notify`.`otype` IN (?, ?)",
Notify\ObjectType::ITEM, Notify\ObjectType::PERSON)) {
return Update::FAILED;
}
if (!DBA::e("UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`parent` SET `notify`.`parent-uri-id` = `item`.`uri-id` WHERE `notify`.`parent-uri-id` IS NULL AND `notify`.`otype` IN (?, ?)",
Notify\ObjectType::ITEM, Notify\ObjectType::PERSON)) {
return Update::FAILED;
}
return Update::SUCCESS;
}