When an inbox message is sent to a group, and any member reads it, it is
marked as read by all members.
This commit is contained in:
parent
1ec0ec5961
commit
368ef7d411
4 changed files with 62 additions and 2 deletions
|
|
@ -31,6 +31,7 @@ my $quiet; # this line required
|
|||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
messageStateCleanup($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
|
@ -44,6 +45,37 @@ finish($session); # this line required
|
|||
# print "DONE!\n" unless $quiet;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
sub messageStateCleanup {
|
||||
my $session = shift;
|
||||
my $db = $session->db;
|
||||
|
||||
# Acquire messageIds to fine orphans (no inbox message associated) and those with group delivered system messages marked as completed
|
||||
#
|
||||
my $messageListRef = $db->buildArrayRef("SELECT distinct messageId FROM inbox_messageState WHERE isRead=0 AND deleted = 0");
|
||||
my $sth = $db->read("SELECT status,groupId FROM inbox WHERE messageId=?");
|
||||
for my $messageId (@$messageListRef) {
|
||||
$sth->execute([$messageId]);
|
||||
my $rows = $sth->rows;
|
||||
|
||||
# No reference to any current message in the inbox
|
||||
#
|
||||
if ( !$rows ) {
|
||||
$db->write( "DELETE FROM inbox_messageState WHERE messageId=?", [$messageId] );
|
||||
}
|
||||
else {
|
||||
# test messages for values of completed status and group delivery
|
||||
#
|
||||
while ( my ( $status, $groupId ) = $sth->array ) {
|
||||
next if $status ne "completed" || !$groupId;
|
||||
$db->write( "UPDATE inbox_messageState SET isRead=1 WHERE messageId=?", [$messageId] );
|
||||
}
|
||||
}
|
||||
} ## end for my $messageId (@$messageListRef)
|
||||
$sth->finish;
|
||||
} ## end sub messageStateCleanup
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue