notifications marked as seen when faving, repeating and expanding an notice #306
This commit is contained in:
parent
fd43133f0f
commit
5ed9d729ea
|
@ -678,9 +678,33 @@ class QvitterPlugin extends Plugin {
|
||||||
if($notice->profile_id != $profile->id) {
|
if($notice->profile_id != $profile->id) {
|
||||||
$this->insertNotification($notice->profile_id, $profile->id, 'like', $notice->id);
|
$this->insertNotification($notice->profile_id, $profile->id, 'like', $notice->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mark reply and mention notifications as seen if i'm liking a notice i'm notified about
|
||||||
|
self::markNotificationAsSeen($notice->id,$profile->id,'mention');
|
||||||
|
self::markNotificationAsSeen($notice->id,$profile->id,'reply');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark single notification as seen
|
||||||
|
*/
|
||||||
|
public function markNotificationAsSeen($notice_id, $to_profile_id, $ntype)
|
||||||
|
{
|
||||||
|
$notification_to_mark_as_seen = QvitterNotification::pkeyGet(array(
|
||||||
|
'is_seen' => 0,
|
||||||
|
'notice_id' => $notice_id,
|
||||||
|
'to_profile_id' => $to_profile_id,
|
||||||
|
'ntype' => $ntype
|
||||||
|
));
|
||||||
|
if($notification_to_mark_as_seen instanceof QvitterNotification) {
|
||||||
|
$orig = clone($notification_to_mark_as_seen);
|
||||||
|
$notification_to_mark_as_seen->is_seen = 1;
|
||||||
|
$notification_to_mark_as_seen->update($orig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove likes in notification table on dislike
|
* Remove likes in notification table on dislike
|
||||||
*/
|
*/
|
||||||
|
@ -712,16 +736,8 @@ class QvitterPlugin extends Plugin {
|
||||||
|
|
||||||
// mark reply/mention-notifications as read if we're replying to a notice we're notified about
|
// mark reply/mention-notifications as read if we're replying to a notice we're notified about
|
||||||
if($notice->reply_to) {
|
if($notice->reply_to) {
|
||||||
|
self::markNotificationAsSeen($notice->reply_to,$notice->profile_id,'mention');
|
||||||
$notification_to_mark_as_seen = QvitterNotification::pkeyGet(array('is_seen' => 0,
|
self::markNotificationAsSeen($notice->reply_to,$notice->profile_id,'reply');
|
||||||
'notice_id' => $notice->reply_to,
|
|
||||||
'to_profile_id' => $notice->profile_id));
|
|
||||||
if($notification_to_mark_as_seen instanceof QvitterNotification
|
|
||||||
&& ($notification_to_mark_as_seen->ntype == 'mention' || $notification_to_mark_as_seen->ntype == 'reply')) {
|
|
||||||
$orig = clone($notification_to_mark_as_seen);
|
|
||||||
$notification_to_mark_as_seen->is_seen = 1;
|
|
||||||
$notification_to_mark_as_seen->update($orig);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// repeats
|
// repeats
|
||||||
|
@ -729,6 +745,10 @@ class QvitterPlugin extends Plugin {
|
||||||
$repeated_notice = Notice::getKV('id', $notice->repeat_of);
|
$repeated_notice = Notice::getKV('id', $notice->repeat_of);
|
||||||
if ($repeated_notice instanceof Notice) {
|
if ($repeated_notice instanceof Notice) {
|
||||||
$this->insertNotification($repeated_notice->profile_id, $notice->profile_id, 'repeat', $repeated_notice->id);
|
$this->insertNotification($repeated_notice->profile_id, $notice->profile_id, 'repeat', $repeated_notice->id);
|
||||||
|
|
||||||
|
// mark reply/mention-notifications as read if we're repeating to a notice we're notified about
|
||||||
|
self::markNotificationAsSeen($repeated_notice->id,$notice->profile_id,'mention');
|
||||||
|
self::markNotificationAsSeen($repeated_notice->id,$notice->profile_id,'reply');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,16 @@ class ApiFavsAndRepeatsAction extends ApiPrivateAuthAction
|
||||||
parent::handle();
|
parent::handle();
|
||||||
|
|
||||||
|
|
||||||
|
// since this api method is in practice only used when expanding a
|
||||||
|
// notice, we can assume the user has seen the notice in question,
|
||||||
|
// an no longer need a notification about it. mark reply/mention-
|
||||||
|
// notifications tied to this notice and the current profile as read
|
||||||
|
if($this->auth_user) {
|
||||||
|
QvitterPlugin::markNotificationAsSeen($this->notice_id,$this->auth_user->id,'mention');
|
||||||
|
QvitterPlugin::markNotificationAsSeen($this->notice_id,$this->auth_user->id,'reply');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// favs
|
// favs
|
||||||
$fave = new Fave();
|
$fave = new Fave();
|
||||||
$fave->selectAdd();
|
$fave->selectAdd();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user