[ticket/16544] Correctly mark notification read

PHPBB3-16544
This commit is contained in:
rxu 2020-09-02 22:10:37 +07:00
parent 02f54ef219
commit 8e2dd65c6e
No known key found for this signature in database
GPG key ID: 955F0567380E586A
2 changed files with 42 additions and 38 deletions

View file

@ -580,6 +580,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
'notification.type.post', 'notification.type.post',
'notification.type.approve_topic', 'notification.type.approve_topic',
'notification.type.approve_post', 'notification.type.approve_post',
'notification.type.forum',
), false, $user->data['user_id'], $post_time); ), false, $user->data['user_id'], $post_time);
if ($config['load_db_lastread'] && $user->data['is_registered']) if ($config['load_db_lastread'] && $user->data['is_registered'])
@ -663,6 +664,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
'notification.type.bookmark', 'notification.type.bookmark',
'notification.type.post', 'notification.type.post',
'notification.type.approve_post', 'notification.type.approve_post',
'notification.type.forum',
), $topic_ids, $user->data['user_id'], $post_time); ), $topic_ids, $user->data['user_id'], $post_time);
// Add 0 to forums array to mark global announcements correctly // Add 0 to forums array to mark global announcements correctly
@ -773,6 +775,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
'notification.type.bookmark', 'notification.type.bookmark',
'notification.type.post', 'notification.type.post',
'notification.type.approve_post', 'notification.type.approve_post',
'notification.type.forum',
), $topic_id, $user->data['user_id'], $post_time); ), $topic_id, $user->data['user_id'], $post_time);
if ($config['load_db_lastread'] && $user->data['is_registered']) if ($config['load_db_lastread'] && $user->data['is_registered'])

View file

@ -1,54 +1,54 @@
<?php <?php
/** /**
* *
* This file is part of the phpBB Forum Software package. * This file is part of the phpBB Forum Software package.
* *
* @copyright (c) phpBB Limited <https://www.phpbb.com> * @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0) * @license GNU General Public License, version 2 (GPL-2.0)
* *
* For full copyright and license information, please see * For full copyright and license information, please see
* the docs/CREDITS.txt file. * the docs/CREDITS.txt file.
* *
*/ */
namespace phpbb\notification\type; namespace phpbb\notification\type;
/** /**
* Forum notifications class * Forum notifications class
* This class handles notifications for replies to a topic in a forum user subscribed to * This class handles notifications for replies to a topic in a forum user subscribed to
*/ */
class forum extends \phpbb\notification\type\post class forum extends \phpbb\notification\type\post
{ {
/** /**
* Get notification type name * Get notification type name
* *
* @return string * @return string
*/ */
public function get_type() public function get_type()
{ {
return 'notification.type.forum'; return 'notification.type.forum';
} }
/** /**
* Notification option data (for outputting to the user) * Notification option data (for outputting to the user)
* *
* @var bool|array False if the service should use it's default data * @var bool|array False if the service should use its default data
* Array of data (including keys 'id', 'lang', and 'group') * Array of data (including keys 'id', 'lang', and 'group')
*/ */
static public $notification_option = [ static public $notification_option = [
'lang' => 'NOTIFICATION_TYPE_FORUM', 'lang' => 'NOTIFICATION_TYPE_FORUM',
'group' => 'NOTIFICATION_GROUP_POSTING', 'group' => 'NOTIFICATION_GROUP_POSTING',
]; ];
/** /**
* Find the users who want to receive notifications * Find the users who want to receive notifications
* *
* @param array $post Data from submit_post * @param array $post Data from submit_post
* @param array $options Options for finding users for notification * @param array $options Options for finding users for notification
* *
* @return array * @return array
*/ */
public function find_users_for_notification($post, $options = []) public function find_users_for_notification($post, $options = [])
{ {
$options = array_merge([ $options = array_merge([
@ -76,7 +76,8 @@ class forum extends \phpbb\notification\type\post
return []; return [];
} }
// Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications // Try to find the users who already have been notified about replies and have not read them
// Just update their notifications
$notified_users = $this->notification_manager->get_notified_users($this->get_type(), [ $notified_users = $this->notification_manager->get_notified_users($this->get_type(), [
'item_parent_id' => static::get_item_parent_id($post), 'item_parent_id' => static::get_item_parent_id($post),
'read' => 0, 'read' => 0,
@ -103,20 +104,20 @@ class forum extends \phpbb\notification\type\post
} }
/** /**
* Get email template * Get email template
* *
* @return string|bool * @return string|bool
*/ */
public function get_email_template() public function get_email_template()
{ {
return 'forum_notify'; return 'forum_notify';
} }
/** /**
* Get email template variables * Get email template variables
* *
* @return array * @return array
*/ */
public function get_email_template_variables() public function get_email_template_variables()
{ {
if ($this->get_data('post_username')) if ($this->get_data('post_username'))