Merge pull request #6345 from MrPetovan/bug/6283-clear-message-notifications
Clear private message notifications
This commit is contained in:
commit
e7ee3d7200
26
boot.php
26
boot.php
|
@ -164,21 +164,21 @@ define('MAX_LIKERS', 75);
|
||||||
* Email notification options
|
* Email notification options
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
define('NOTIFY_INTRO', 0x0001);
|
define('NOTIFY_INTRO', 1);
|
||||||
define('NOTIFY_CONFIRM', 0x0002);
|
define('NOTIFY_CONFIRM', 2);
|
||||||
define('NOTIFY_WALL', 0x0004);
|
define('NOTIFY_WALL', 4);
|
||||||
define('NOTIFY_COMMENT', 0x0008);
|
define('NOTIFY_COMMENT', 8);
|
||||||
define('NOTIFY_MAIL', 0x0010);
|
define('NOTIFY_MAIL', 16);
|
||||||
define('NOTIFY_SUGGEST', 0x0020);
|
define('NOTIFY_SUGGEST', 32);
|
||||||
define('NOTIFY_PROFILE', 0x0040);
|
define('NOTIFY_PROFILE', 64);
|
||||||
define('NOTIFY_TAGSELF', 0x0080);
|
define('NOTIFY_TAGSELF', 128);
|
||||||
define('NOTIFY_TAGSHARE', 0x0100);
|
define('NOTIFY_TAGSHARE', 256);
|
||||||
define('NOTIFY_POKE', 0x0200);
|
define('NOTIFY_POKE', 512);
|
||||||
define('NOTIFY_SHARE', 0x0400);
|
define('NOTIFY_SHARE', 1024);
|
||||||
|
|
||||||
define('SYSTEM_EMAIL', 0x4000);
|
define('SYSTEM_EMAIL', 16384);
|
||||||
|
|
||||||
define('NOTIFY_SYSTEM', 0x8000);
|
define('NOTIFY_SYSTEM', 32768);
|
||||||
/* @}*/
|
/* @}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -303,41 +303,58 @@ function message_content(App $a)
|
||||||
|
|
||||||
$o .= $header;
|
$o .= $header;
|
||||||
|
|
||||||
$r = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
|
$message = DBA::fetchFirst("
|
||||||
FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
|
SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
|
||||||
WHERE `mail`.`uid` = %d AND `mail`.`id` = %d LIMIT 1",
|
FROM `mail`
|
||||||
intval(local_user()),
|
LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
|
||||||
intval($a->argv[1])
|
WHERE `mail`.`uid` = ? AND `mail`.`id` = ?
|
||||||
|
LIMIT 1",
|
||||||
|
local_user(),
|
||||||
|
$a->argv[1]
|
||||||
);
|
);
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($message)) {
|
||||||
$contact_id = $r[0]['contact-id'];
|
$contact_id = $message['contact-id'];
|
||||||
$convid = $r[0]['convid'];
|
|
||||||
|
|
||||||
$sql_extra = sprintf(" and `mail`.`parent-uri` = '%s' ", DBA::escape($r[0]['parent-uri']));
|
$params = [
|
||||||
if ($convid)
|
local_user(),
|
||||||
$sql_extra = sprintf(" and ( `mail`.`parent-uri` = '%s' OR `mail`.`convid` = '%d' ) ",
|
$message['parent-uri']
|
||||||
DBA::escape($r[0]['parent-uri']),
|
];
|
||||||
intval($convid)
|
|
||||||
);
|
|
||||||
|
|
||||||
$messages = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
|
if ($message['convid']) {
|
||||||
FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
|
$sql_extra = "AND (`mail`.`parent-uri` = ? OR `mail`.`convid` = ?)";
|
||||||
WHERE `mail`.`uid` = %d $sql_extra ORDER BY `mail`.`created` ASC",
|
$params[] = $message['convid'];
|
||||||
intval(local_user())
|
} else {
|
||||||
|
$sql_extra = "AND `mail`.`parent-uri` = ?";
|
||||||
|
}
|
||||||
|
$messages_stmt = DBA::p("
|
||||||
|
SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
|
||||||
|
FROM `mail`
|
||||||
|
LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
|
||||||
|
WHERE `mail`.`uid` = ?
|
||||||
|
$sql_extra
|
||||||
|
ORDER BY `mail`.`created` ASC",
|
||||||
|
...$params
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$messages = DBA::toArray($messages_stmt);
|
||||||
|
|
||||||
|
DBA::update('mail', ['seen' => 1], ['parent-uri' => $message['parent-uri'], 'uid' => local_user()]);
|
||||||
|
|
||||||
|
if ($message['convid']) {
|
||||||
|
// Clear Diaspora private message notifications
|
||||||
|
DBA::update('notify', ['seen' => 1], ['type' => NOTIFY_MAIL, 'parent' => $message['convid'], 'uid' => local_user()]);
|
||||||
|
}
|
||||||
|
// Clear DFRN private message notifications
|
||||||
|
DBA::update('notify', ['seen' => 1], ['type' => NOTIFY_MAIL, 'parent' => $message['parent-uri'], 'uid' => local_user()]);
|
||||||
} else {
|
} else {
|
||||||
$messages = false;
|
$messages = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DBA::isResult($messages)) {
|
if (!DBA::isResult($messages)) {
|
||||||
notice(L10n::t('Message not available.') . EOL);
|
notice(L10n::t('Message not available.') . EOL);
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("UPDATE `mail` SET `seen` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d",
|
|
||||||
DBA::escape($r[0]['parent-uri']),
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('msg-header.tpl');
|
$tpl = Renderer::getMarkupTemplate('msg-header.tpl');
|
||||||
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
||||||
'$baseurl' => System::baseUrl(true),
|
'$baseurl' => System::baseUrl(true),
|
||||||
|
@ -350,8 +367,10 @@ function message_content(App $a)
|
||||||
$unknown = false;
|
$unknown = false;
|
||||||
|
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
if ($message['unknown'])
|
if ($message['unknown']) {
|
||||||
$unknown = true;
|
$unknown = true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($message['from-url'] == $myprofile) {
|
if ($message['from-url'] == $myprofile) {
|
||||||
$from_url = $myprofile;
|
$from_url = $myprofile;
|
||||||
$sparkle = '';
|
$sparkle = '';
|
||||||
|
@ -499,7 +518,6 @@ function render_messages(array $msg, $t)
|
||||||
$participants = L10n::t("%s and You", $rr['from-name']);
|
$participants = L10n::t("%s and You", $rr['from-name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$subject_e = (($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>');
|
|
||||||
$body_e = $rr['body'];
|
$body_e = $rr['body'];
|
||||||
$to_name_e = $rr['name'];
|
$to_name_e = $rr['name'];
|
||||||
|
|
||||||
|
@ -517,7 +535,7 @@ function render_messages(array $msg, $t)
|
||||||
'$from_addr' => defaults($contact, 'addr', ''),
|
'$from_addr' => defaults($contact, 'addr', ''),
|
||||||
'$sparkle' => ' sparkle',
|
'$sparkle' => ' sparkle',
|
||||||
'$from_photo' => ProxyUtils::proxifyUrl($from_photo, false, ProxyUtils::SIZE_THUMB),
|
'$from_photo' => ProxyUtils::proxifyUrl($from_photo, false, ProxyUtils::SIZE_THUMB),
|
||||||
'$subject' => $subject_e,
|
'$subject' => $rr['title'],
|
||||||
'$delete' => L10n::t('Delete conversation'),
|
'$delete' => L10n::t('Delete conversation'),
|
||||||
'$body' => $body_e,
|
'$body' => $body_e,
|
||||||
'$to_name' => $to_name_e,
|
'$to_name' => $to_name_e,
|
||||||
|
|
31
mod/ping.php
31
mod/ping.php
|
@ -64,14 +64,7 @@ function ping_init(App $a)
|
||||||
$format = 'json';
|
$format = 'json';
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags = [];
|
|
||||||
$comments = [];
|
|
||||||
$likes = [];
|
|
||||||
$dislikes = [];
|
|
||||||
$friends = [];
|
|
||||||
$posts = [];
|
|
||||||
$regs = [];
|
$regs = [];
|
||||||
$mails = [];
|
|
||||||
$notifications = [];
|
$notifications = [];
|
||||||
|
|
||||||
$intro_count = 0;
|
$intro_count = 0;
|
||||||
|
@ -282,22 +275,6 @@ function ping_init(App $a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBA::isResult($mails)) {
|
|
||||||
foreach ($mails as $mail) {
|
|
||||||
$notif = [
|
|
||||||
'id' => 0,
|
|
||||||
'href' => System::baseUrl() . '/message/' . $mail['id'],
|
|
||||||
'name' => $mail['from-name'],
|
|
||||||
'url' => $mail['from-url'],
|
|
||||||
'photo' => $mail['from-photo'],
|
|
||||||
'date' => $mail['created'],
|
|
||||||
'seen' => false,
|
|
||||||
'message' => L10n::t('{0} sent you a message'),
|
|
||||||
];
|
|
||||||
$notifs[] = $notif;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DBA::isResult($regs)) {
|
if (DBA::isResult($regs)) {
|
||||||
foreach ($regs as $reg) {
|
foreach ($regs as $reg) {
|
||||||
$notif = [
|
$notif = [
|
||||||
|
@ -384,7 +361,7 @@ function ping_init(App $a)
|
||||||
if ($format == 'json') {
|
if ($format == 'json') {
|
||||||
$data['groups'] = $groups_unseen;
|
$data['groups'] = $groups_unseen;
|
||||||
$data['forums'] = $forums_unseen;
|
$data['forums'] = $forums_unseen;
|
||||||
$data['notify'] = $sysnotify_count + $intro_count + $mail_count + $register_count;
|
$data['notify'] = $sysnotify_count + $intro_count + $register_count;
|
||||||
$data['notifications'] = $notifications;
|
$data['notifications'] = $notifications;
|
||||||
$data['sysmsgs'] = [
|
$data['sysmsgs'] = [
|
||||||
'notice' => $sysmsgs,
|
'notice' => $sysmsgs,
|
||||||
|
@ -427,8 +404,6 @@ function ping_get_notifications($uid)
|
||||||
$order = "DESC";
|
$order = "DESC";
|
||||||
$quit = false;
|
$quit = false;
|
||||||
|
|
||||||
$a = get_app();
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$r = q(
|
$r = q(
|
||||||
"SELECT `notify`.*, `item`.`visible`, `item`.`deleted`
|
"SELECT `notify`.*, `item`.`visible`, `item`.`deleted`
|
||||||
|
@ -505,8 +480,8 @@ function ping_get_notifications($uid)
|
||||||
* @param array $notifs Complete list of notification
|
* @param array $notifs Complete list of notification
|
||||||
* @param array $sysmsgs List of system notice messages
|
* @param array $sysmsgs List of system notice messages
|
||||||
* @param array $sysmsgs_info List of system info messages
|
* @param array $sysmsgs_info List of system info messages
|
||||||
* @param int $groups_unseen Number of unseen group items
|
* @param array $groups_unseen List of unseen group messages
|
||||||
* @param int $forums_unseen Number of unseen forum items
|
* @param array $forums_unseen List of unseen forum messages
|
||||||
*
|
*
|
||||||
* @return array XML-transform ready data array
|
* @return array XML-transform ready data array
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1870,6 +1870,7 @@ class DFRN
|
||||||
"to_email" => $importer["email"],
|
"to_email" => $importer["email"],
|
||||||
"uid" => $importer["importer_uid"],
|
"uid" => $importer["importer_uid"],
|
||||||
"item" => $msg,
|
"item" => $msg,
|
||||||
|
"parent" => $msg["parent-uri"],
|
||||||
"source_name" => $msg["from-name"],
|
"source_name" => $msg["from-name"],
|
||||||
"source_link" => $importer["url"],
|
"source_link" => $importer["url"],
|
||||||
"source_photo" => $importer["thumb"],
|
"source_photo" => $importer["thumb"],
|
||||||
|
|
|
@ -1807,44 +1807,45 @@ class Diaspora
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
q(
|
DBA::insert('mail', [
|
||||||
"INSERT INTO `mail` (`uid`, `guid`, `convid`, `from-name`,`from-photo`,`from-url`,`contact-id`,`title`,`body`,`seen`,`reply`,`uri`,`parent-uri`,`created`)
|
'uid' => $importer['uid'],
|
||||||
VALUES (%d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s','%s','%s')",
|
'guid' => $msg_guid,
|
||||||
intval($importer["uid"]),
|
'convid' => $conversation['id'],
|
||||||
DBA::escape($msg_guid),
|
'from-name' => $person['name'],
|
||||||
intval($conversation["id"]),
|
'from-photo' => $person['photo'],
|
||||||
DBA::escape($person["name"]),
|
'from-url' => $person['url'],
|
||||||
DBA::escape($person["photo"]),
|
'contact-id' => $contact['id'],
|
||||||
DBA::escape($person["url"]),
|
'title' => $subject,
|
||||||
intval($contact["id"]),
|
'body' => $body,
|
||||||
DBA::escape($subject),
|
'seen' => 0,
|
||||||
DBA::escape($body),
|
'reply' => 0,
|
||||||
0,
|
'uri' => $message_uri,
|
||||||
0,
|
'parent-uri' => $author . ':' . $guid,
|
||||||
DBA::escape($message_uri),
|
'created' => $msg_created_at
|
||||||
DBA::escape($author.":".$guid),
|
]);
|
||||||
DBA::escape($msg_created_at)
|
|
||||||
);
|
$message_id = DBA::lastInsertId();
|
||||||
|
|
||||||
DBA::unlock();
|
DBA::unlock();
|
||||||
|
|
||||||
DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
|
DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
|
||||||
|
|
||||||
notification(
|
notification([
|
||||||
[
|
|
||||||
"type" => NOTIFY_MAIL,
|
"type" => NOTIFY_MAIL,
|
||||||
"notify_flags" => $importer["notify-flags"],
|
"notify_flags" => $importer["notify-flags"],
|
||||||
"language" => $importer["language"],
|
"language" => $importer["language"],
|
||||||
"to_name" => $importer["username"],
|
"to_name" => $importer["username"],
|
||||||
"to_email" => $importer["email"],
|
"to_email" => $importer["email"],
|
||||||
"uid" =>$importer["uid"],
|
"uid" => $importer["uid"],
|
||||||
"item" => ["id" => $conversation["id"], "title" => $subject, "subject" => $subject, "body" => $body],
|
"item" => ["id" => $message_id, "title" => $subject, "subject" => $subject, "body" => $body],
|
||||||
|
"parent" => $conversation["id"],
|
||||||
"source_name" => $person["name"],
|
"source_name" => $person["name"],
|
||||||
"source_link" => $person["url"],
|
"source_link" => $person["url"],
|
||||||
"source_photo" => $person["photo"],
|
"source_photo" => $person["photo"],
|
||||||
"verb" => ACTIVITY_POST,
|
"verb" => ACTIVITY_POST,
|
||||||
"otype" => "mail"]
|
"otype" => "mail"
|
||||||
);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2066,28 +2067,45 @@ class Diaspora
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
q(
|
DBA::insert('mail', [
|
||||||
"INSERT INTO `mail` (`uid`, `guid`, `convid`, `from-name`,`from-photo`,`from-url`,`contact-id`,`title`,`body`,`seen`,`reply`,`uri`,`parent-uri`,`created`)
|
'uid' => $importer['uid'],
|
||||||
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s','%s','%s')",
|
'guid' => $guid,
|
||||||
intval($importer["uid"]),
|
'convid' => $conversation['id'],
|
||||||
DBA::escape($guid),
|
'from-name' => $person['name'],
|
||||||
intval($conversation["id"]),
|
'from-photo' => $person['photo'],
|
||||||
DBA::escape($person["name"]),
|
'from-url' => $person['url'],
|
||||||
DBA::escape($person["photo"]),
|
'contact-id' => $contact['id'],
|
||||||
DBA::escape($person["url"]),
|
'title' => $conversation['subject'],
|
||||||
intval($contact["id"]),
|
'body' => $body,
|
||||||
DBA::escape($conversation["subject"]),
|
'seen' => 0,
|
||||||
DBA::escape($body),
|
'reply' => 1,
|
||||||
0,
|
'uri' => $message_uri,
|
||||||
1,
|
'parent-uri' => $author.":".$conversation['guid'],
|
||||||
DBA::escape($message_uri),
|
'created' => $created_at
|
||||||
DBA::escape($author.":".$conversation["guid"]),
|
]);
|
||||||
DBA::escape($created_at)
|
|
||||||
);
|
$message_id = DBA::lastInsertId();
|
||||||
|
|
||||||
DBA::unlock();
|
DBA::unlock();
|
||||||
|
|
||||||
DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
|
DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
|
||||||
|
|
||||||
|
notification([
|
||||||
|
"type" => NOTIFY_MAIL,
|
||||||
|
"notify_flags" => $importer["notify-flags"],
|
||||||
|
"language" => $importer["language"],
|
||||||
|
"to_name" => $importer["username"],
|
||||||
|
"to_email" => $importer["email"],
|
||||||
|
"uid" => $importer["uid"],
|
||||||
|
"item" => ["id" => $message_id, "title" => $conversation["subject"], "subject" => $conversation["subject"], "body" => $body],
|
||||||
|
"parent" => $conversation["id"],
|
||||||
|
"source_name" => $person["name"],
|
||||||
|
"source_link" => $person["url"],
|
||||||
|
"source_photo" => $person["photo"],
|
||||||
|
"verb" => ACTIVITY_POST,
|
||||||
|
"otype" => "mail"
|
||||||
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,16 @@
|
||||||
<div class="text-muted time ago pull-right" title="{{$date}}">{{$ago}}</div>
|
<div class="text-muted time ago pull-right" title="{{$date}}">{{$ago}}</div>
|
||||||
|
|
||||||
<h4 class="media-heading">{{$from_name}}</h4>
|
<h4 class="media-heading">{{$from_name}}</h4>
|
||||||
<div class="mail-list-subject"><a href="message/{{$id}}">{{$subject}}</a></div>
|
<div class="mail-list-subject">
|
||||||
|
<a href="message/{{$id}}">
|
||||||
|
{{if !$seen}}
|
||||||
|
<strong>
|
||||||
|
{{/if}}
|
||||||
|
{{$subject}}
|
||||||
|
{{if !$seen}}
|
||||||
|
</strong>
|
||||||
|
{{/if}}
|
||||||
|
</a></div>
|
||||||
<a href="message/dropconv/{{$id}}" onclick="return confirmDelete();" title="{{$delete}}" class="pull-right" onmouseover="imgbright(this);" onmouseout="imgdull(this);">
|
<a href="message/dropconv/{{$id}}" onclick="return confirmDelete();" title="{{$delete}}" class="pull-right" onmouseover="imgbright(this);" onmouseout="imgdull(this);">
|
||||||
<i class="faded-icon fa fa-trash"></i>
|
<i class="faded-icon fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user