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

@ -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])) {

View file

@ -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;

View file

@ -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.

View file

@ -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);