The notifications parameters are now simplified
This commit is contained in:
parent
32f70abf9a
commit
818c064c0a
17 changed files with 143 additions and 187 deletions
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2020.12-dev (Red Hot Poker)
|
||||
-- DB_UPDATE_VERSION 1379
|
||||
-- DB_UPDATE_VERSION 1380
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Core\Renderer;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\ItemContent;
|
||||
use Friendica\Model\Notify;
|
||||
|
@ -37,10 +38,10 @@ use Friendica\Protocol\Activity;
|
|||
* Creates a notification entry and possibly sends a mail
|
||||
*
|
||||
* @param array $params Array with the elements:
|
||||
* uid, item, parent, type, otype, verb, event,
|
||||
* link, subject, body, to_name, to_email, source_name,
|
||||
* source_link, activity, preamble, notify_flags,
|
||||
* language, show_in_notification_page
|
||||
* type, event, otype, activity, verb, uid, cid, origin_cid, item, link,
|
||||
* source_name, source_mail, source_nick, source_link, source_photo,
|
||||
* show_in_notification_page
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
|
@ -55,7 +56,7 @@ function notification($params)
|
|||
}
|
||||
|
||||
// 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']]);
|
||||
|
||||
if (!DBA::isResult($user)) {
|
||||
|
@ -63,14 +64,39 @@ function notification($params)
|
|||
return false;
|
||||
}
|
||||
|
||||
$params['notify_flags'] = ($params['notify_flags'] ?? '') ?: $user['notify-flags'];
|
||||
$params['language'] = ($params['language'] ?? '') ?: $user['language'];
|
||||
$params['to_name'] = ($params['to_name'] ?? '') ?: $user['username'];
|
||||
$params['to_email'] = ($params['to_email'] ?? '') ?: $user['email'];
|
||||
// There is no need to create notifications for forum accounts
|
||||
if (in_array($user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$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);
|
||||
$sitename = DI::config()->get('config', 'sitename');
|
||||
|
||||
|
@ -79,14 +105,6 @@ function notification($params)
|
|||
$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
|
||||
$emailBuilder = DI::emailer()->newNotifyMail();
|
||||
|
||||
|
@ -97,36 +115,13 @@ function notification($params)
|
|||
|
||||
$emailBuilder->setHeader('X-Friendica-Account', '<' . $nickname . '@' . $hostname . '>');
|
||||
|
||||
if (array_key_exists('item', $params)) {
|
||||
$title = $params['item']['title'];
|
||||
$body = $params['item']['body'];
|
||||
} else {
|
||||
$title = $body = '';
|
||||
}
|
||||
$title = $params['item']['title'] ?? '';
|
||||
$body = $params['item']['body'] ?? '';
|
||||
|
||||
if (isset($params['item']['id'])) {
|
||||
$item_id = $params['item']['id'];
|
||||
} else {
|
||||
$item_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;
|
||||
}
|
||||
$item_id = $params['item']['id'] ?? 0;
|
||||
$uri_id = $params['item']['uri-id'] ?? 0;
|
||||
$parent_id = $params['item']['parent'] ?? 0;
|
||||
$parent_uri_id = $params['item']['parent-uri-id'] ?? 0;
|
||||
|
||||
$epreamble = '';
|
||||
$preamble = '';
|
||||
|
@ -137,8 +132,7 @@ function notification($params)
|
|||
$itemlink = '';
|
||||
|
||||
if ($params['type'] == Notify\Type::MAIL) {
|
||||
$itemlink = $siteurl.'/message/'.$params['item']['id'];
|
||||
$params["link"] = $itemlink;
|
||||
$itemlink = $params['link'];
|
||||
|
||||
$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]');
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to view and/or reply to your private messages.');
|
||||
$tsitelink = sprintf($sitelink, $siteurl.'/message/'.$params['item']['id']);
|
||||
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'/message/'.$params['item']['id'].'">'.$sitename.'</a>');
|
||||
$tsitelink = sprintf($sitelink, $itemlink);
|
||||
$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) {
|
||||
|
@ -493,10 +490,10 @@ function notification($params)
|
|||
if (!empty($uri_id)) {
|
||||
$fields['uri-id'] = $uri_id;
|
||||
}
|
||||
if (!empty($item_id)) {
|
||||
if (!empty($parent_id)) {
|
||||
$fields['parent'] = $parent_id;
|
||||
}
|
||||
if (!empty($item_id)) {
|
||||
if (!empty($parent_uri_id)) {
|
||||
$fields['parent-uri-id'] = $parent_uri_id;
|
||||
}
|
||||
$notification = DI::notify()->insert($fields);
|
||||
|
@ -628,14 +625,11 @@ function check_item_notification($itemid, $uid, $notification_type) {
|
|||
|
||||
// Generate the notification array
|
||||
$params = [];
|
||||
$params['otype'] = Notify\ObjectType::ITEM;
|
||||
$params['uid'] = $uid;
|
||||
$params['origin_cid'] = $params['cid'] = $item['author-id'];
|
||||
$params['item'] = $item;
|
||||
$params['parent'] = $item['parent'];
|
||||
$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
|
||||
$params['activity']['explicit_tagged'] = ($notification_type & UserItem::NOTIF_EXPLICIT_TAGGED);
|
||||
|
@ -663,9 +657,7 @@ function check_item_notification($itemid, $uid, $notification_type) {
|
|||
return false;
|
||||
}
|
||||
|
||||
$params['origin_name'] = $parent_item['author-name'];
|
||||
$params['origin_link'] = $parent_item['author-link'];
|
||||
$params['origin_photo'] = $parent_item['author-avatar'];
|
||||
$params['origin_cid'] = $parent_item['author-id'];
|
||||
$params['item'] = $parent_item;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Notify;
|
||||
use Friendica\Model\Notify\Type;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Protocol\Activity;
|
||||
|
@ -542,18 +543,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
if ($combined['notify-flags'] & Type::CONFIRM) {
|
||||
$mutual = ($new_relation == Contact::FRIEND);
|
||||
notification([
|
||||
'type' => Type::CONFIRM,
|
||||
'notify_flags' => $combined['notify-flags'],
|
||||
'language' => $combined['language'],
|
||||
'to_name' => $combined['username'],
|
||||
'to_email' => $combined['email'],
|
||||
'uid' => $combined['uid'],
|
||||
'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'
|
||||
'type' => Type::CONFIRM,
|
||||
'otype' => Notify\ObjectType::INTRO,
|
||||
'verb' => ($mutual ? Activity::FRIEND : Activity::FOLLOW),
|
||||
'uid' => $combined['uid'],
|
||||
'cid' => $combined['id'],
|
||||
'link' => DI::baseUrl() . '/contact/' . $dfrn_record,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Notify;
|
||||
use Friendica\Model\Notify\Type;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\User;
|
||||
|
@ -559,18 +560,12 @@ function dfrn_request_content(App $a)
|
|||
|
||||
if (!$auto_confirm) {
|
||||
notification([
|
||||
'type' => Type::INTRO,
|
||||
'notify_flags' => $r[0]['notify-flags'],
|
||||
'language' => $r[0]['language'],
|
||||
'to_name' => $r[0]['username'],
|
||||
'to_email' => $r[0]['email'],
|
||||
'uid' => $r[0]['uid'],
|
||||
'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'
|
||||
'type' => Type::INTRO,
|
||||
'otype' => Notify\ObjectType::INTRO,
|
||||
'verb' => Activity::REQ_FRIEND,
|
||||
'uid' => $r[0]['uid'],
|
||||
'cid' => $r[0]['id'],
|
||||
'link' => DI::baseUrl() . '/notifications/intros',
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
|
||||
if ($update) {
|
||||
$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) {
|
||||
$a->profile = ['uid' => intval($item['uid'])];
|
||||
} else {
|
||||
|
@ -201,7 +201,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
|
||||
if ($a->argc == 2) {
|
||||
$item_parent = 0;
|
||||
$fields = ['id', 'parent', 'parent-uri', 'uid'];
|
||||
$fields = ['id', 'parent', 'parent-uri', 'parent-uri-id', 'uid'];
|
||||
|
||||
if (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')) {
|
||||
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
|
||||
|
|
43
mod/item.php
43
mod/item.php
|
@ -45,6 +45,7 @@ use Friendica\Model\Contact;
|
|||
use Friendica\Model\Conversation;
|
||||
use Friendica\Model\FileTag;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Notify;
|
||||
use Friendica\Model\Notify\Type;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -756,37 +757,23 @@ function item_post(App $a) {
|
|||
if ($contact_record != $author) {
|
||||
if ($toplevel_item_id) {
|
||||
notification([
|
||||
'type' => Type::COMMENT,
|
||||
'notify_flags' => $user['notify-flags'],
|
||||
'language' => $user['language'],
|
||||
'to_name' => $user['username'],
|
||||
'to_email' => $user['email'],
|
||||
'uid' => $user['uid'],
|
||||
'item' => $datarray,
|
||||
'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']
|
||||
'type' => Type::COMMENT,
|
||||
'otype' => Notify\ObjectType::ITEM,
|
||||
'verb' => Activity::POST,
|
||||
'uid' => $user['uid'],
|
||||
'cid' => $datarray['author-id'],
|
||||
'item' => $datarray,
|
||||
'link' => DI::baseUrl() . '/display/' . urlencode($datarray['guid']),
|
||||
]);
|
||||
} elseif (empty($forum_contact)) {
|
||||
notification([
|
||||
'type' => Type::WALL,
|
||||
'notify_flags' => $user['notify-flags'],
|
||||
'language' => $user['language'],
|
||||
'to_name' => $user['username'],
|
||||
'to_email' => $user['email'],
|
||||
'uid' => $user['uid'],
|
||||
'item' => $datarray,
|
||||
'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'
|
||||
'type' => Type::WALL,
|
||||
'otype' => Notify\ObjectType::ITEM,
|
||||
'verb' => Activity::POST,
|
||||
'uid' => $user['uid'],
|
||||
'cid' => $datarray['author-id'],
|
||||
'item' => $datarray,
|
||||
'link' => DI::baseUrl() . '/display/' . urlencode($datarray['guid']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -282,7 +282,6 @@ function message_content(App $a)
|
|||
$messages = DBA::toArray($messages_stmt);
|
||||
|
||||
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 {
|
||||
$messages = false;
|
||||
}
|
||||
|
|
|
@ -1217,6 +1217,7 @@ class Worker
|
|||
// Don't fork from frontend tasks by default
|
||||
$dont_fork = DI::config()->get("system", "worker_dont_fork", false) || !DI::mode()->isBackend();
|
||||
$created = DateTimeFormat::utcNow();
|
||||
$delayed = DBA::NULL_DATETIME;
|
||||
$force_priority = false;
|
||||
|
||||
$run_parameter = array_shift($args);
|
||||
|
@ -1224,6 +1225,9 @@ class Worker
|
|||
if (is_int($run_parameter)) {
|
||||
$priority = $run_parameter;
|
||||
} elseif (is_array($run_parameter)) {
|
||||
if (isset($run_parameter['delayed'])) {
|
||||
$delayed = $run_parameter['execute'];
|
||||
}
|
||||
if (isset($run_parameter['priority'])) {
|
||||
$priority = $run_parameter['priority'];
|
||||
}
|
||||
|
@ -1248,7 +1252,8 @@ class Worker
|
|||
}
|
||||
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2426,18 +2426,12 @@ class Contact
|
|||
in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL])) {
|
||||
|
||||
notification([
|
||||
'type' => Type::INTRO,
|
||||
'notify_flags' => $user['notify-flags'],
|
||||
'language' => $user['language'],
|
||||
'to_name' => $user['username'],
|
||||
'to_email' => $user['email'],
|
||||
'uid' => $user['uid'],
|
||||
'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'
|
||||
'type' => Type::INTRO,
|
||||
'otype' => Notify\ObjectType::INTRO,
|
||||
'verb' => ($sharing ? Activity::FRIEND : Activity::FOLLOW),
|
||||
'uid' => $user['uid'],
|
||||
'cid' => $contact_record['id'],
|
||||
'link' => DI::baseUrl() . '/notifications/intros',
|
||||
]);
|
||||
}
|
||||
} elseif (DBA::isResult($user) && in_array($user['page-flags'], [User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE, User::PAGE_FLAGS_COMMUNITY])) {
|
||||
|
|
|
@ -181,19 +181,13 @@ class FContact
|
|||
DBA::insert('intro', $fields);
|
||||
|
||||
notification([
|
||||
'type' => Type::SUGGEST,
|
||||
'notify_flags' => $owner['notify-flags'],
|
||||
'language' => $owner['language'],
|
||||
'to_name' => $owner['name'],
|
||||
'to_email' => $owner['email'],
|
||||
'uid' => $owner['uid'],
|
||||
'item' => $suggest,
|
||||
'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'
|
||||
'type' => Type::SUGGEST,
|
||||
'otype' => Notify\ObjectType::INTRO,
|
||||
'verb' => Activity::REQ_FRIEND,
|
||||
'uid' => $owner['uid'],
|
||||
'cid' => $from_contact['uid'],
|
||||
'item' => $suggest,
|
||||
'link' => DI::baseUrl().'/notifications/intros',
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1065,9 +1065,6 @@ class Item
|
|||
// "Deleting" global items just means hiding them
|
||||
if ($item['uid'] == 0) {
|
||||
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) {
|
||||
self::markForDeletionById($item['id'], PRIORITY_HIGH);
|
||||
} else {
|
||||
|
@ -1155,9 +1152,6 @@ class Item
|
|||
}
|
||||
}
|
||||
|
||||
// Delete notifications
|
||||
DBA::delete('notify', ['iid' => $item['id'], 'uid' => $item['uid']]);
|
||||
|
||||
// Set the item to "deleted"
|
||||
$item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
|
||||
DBA::update('item', $item_fields, ['id' => $item['id']]);
|
||||
|
@ -1171,9 +1165,6 @@ class Item
|
|||
|
||||
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,
|
||||
// this query here needs to be extended.
|
||||
// @todo Currently deactivated. We need the permission set in the deletion process.
|
||||
|
|
|
@ -84,19 +84,12 @@ class Mail
|
|||
|
||||
// send notifications.
|
||||
$notif_params = [
|
||||
'type' => Type::MAIL,
|
||||
'notify_flags' => $user['notify-flags'],
|
||||
'language' => $user['language'],
|
||||
'to_name' => $user['username'],
|
||||
'to_email' => $user['email'],
|
||||
'uid' => $user['uid'],
|
||||
'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'
|
||||
'type' => Type::MAIL,
|
||||
'otype' => Notify\ObjectType::MAIL,
|
||||
'verb' => Activity::POST,
|
||||
'uid' => $user['uid'],
|
||||
'cid' => $msg['contact-id'],
|
||||
'link' => DI::baseUrl() . '/message/' . $msg['id'],
|
||||
];
|
||||
|
||||
notification($notif_params);
|
||||
|
|
|
@ -367,15 +367,13 @@ class Register extends BaseModule
|
|||
\notification([
|
||||
'type' => Model\Notify\Type::SYSTEM,
|
||||
'event' => 'SYSTEM_REGISTER_REQUEST',
|
||||
'uid' => $admin['uid'],
|
||||
'link' => $base_url . '/admin/users/',
|
||||
'source_name' => $user['username'],
|
||||
'source_mail' => $user['email'],
|
||||
'source_nick' => $user['nickname'],
|
||||
'source_link' => $base_url . '/admin/users/',
|
||||
'link' => $base_url . '/admin/users/',
|
||||
'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
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ use Friendica\Model\FContact;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Model\ItemURI;
|
||||
use Friendica\Model\Mail;
|
||||
use Friendica\Model\Notify;
|
||||
use Friendica\Model\Notify\Type;
|
||||
use Friendica\Model\PermissionSet;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -2005,7 +2006,7 @@ class DFRN
|
|||
}
|
||||
|
||||
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"]]);
|
||||
$item['parent'] = $parent['id'];
|
||||
|
@ -2013,21 +2014,15 @@ class DFRN
|
|||
// send a notification
|
||||
notification(
|
||||
[
|
||||
"type" => Type::POKE,
|
||||
"notify_flags" => $importer["notify-flags"],
|
||||
"language" => $importer["language"],
|
||||
"to_name" => $importer["username"],
|
||||
"to_email" => $importer["email"],
|
||||
"uid" => $importer["importer_uid"],
|
||||
"item" => $item,
|
||||
"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']]
|
||||
"type" => Type::POKE,
|
||||
"otype" => Notify\ObjectType::PERSON,
|
||||
"activity" => $verb,
|
||||
"verb" => $item["verb"],
|
||||
"uid" => $importer["importer_uid"],
|
||||
"cid" => $author["id"],
|
||||
"item" => $item,
|
||||
"link" => DI::baseUrl() . "/display/" . urlencode($item['guid']),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
use Friendica\Database\DBA;
|
||||
|
||||
if (!defined('DB_UPDATE_VERSION')) {
|
||||
define('DB_UPDATE_VERSION', 1379);
|
||||
define('DB_UPDATE_VERSION', 1380);
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\Model\Notify;
|
||||
|
||||
return [
|
||||
// Empty these tables
|
||||
'cache',
|
||||
|
@ -317,7 +319,7 @@ return [
|
|||
'iid' => 4,
|
||||
'seen' => 0,
|
||||
'verb' => '',
|
||||
'otype' => 'item',
|
||||
'otype' => Notify\ObjectType::ITEM,
|
||||
'name_cache' => 'Reply to',
|
||||
'msg_cache' => 'A test reply from an item',
|
||||
],
|
||||
|
|
16
update.php
16
update.php
|
@ -50,6 +50,7 @@ use Friendica\Database\DBStructure;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Notify;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Model\Storage;
|
||||
|
@ -856,3 +857,18 @@ function pre_update_1377()
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue