The notifications parameters are now simplified

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

View file

@ -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,
]);
}
}

View file

@ -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',
]);
}

View file

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

View file

@ -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']),
]);
}
}

View file

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