Browse Source

Fix #857, clear message counter when the current user has replied in the history or when a Carbon message from the user was received

pull/898/head
Timothée Jaussoin 6 years ago
parent
commit
86cf98b5d9
  1. 10
      app/Message.php
  2. 2
      lib/moxl/src/Moxl/Xec/Payload/Carbons.php
  3. 1
      lib/moxl/src/Moxl/Xec/Payload/MAMResult.php

10
app/Message.php

@ -93,6 +93,16 @@ class Message extends Model
]);
}
public function clearUnreads()
{
if ($this->jidfrom == $this->user_id) {
$this->user->messages()
->where('jidfrom', $this->jidto)
->where('seen', false)
->update(['seen' => true]);
}
}
public function set($stanza, $parent = false)
{
$this->id = ($stanza->{'stanza-id'} && $stanza->{'stanza-id'}->attributes()->id)

2
lib/moxl/src/Moxl/Xec/Payload/Carbons.php

@ -18,6 +18,8 @@ class Carbons extends Payload
if (!$m->isOTR()) {
$m->save();
$m->clearUnreads();
$this->pack($m);
$this->deliver();
}

1
lib/moxl/src/Moxl/Xec/Payload/MAMResult.php

@ -28,6 +28,7 @@ class MAMResult extends Payload
if (!$message->isOTR()
&& (!$message->isEmpty() || $message->isSubject())) {
$message->save();
$message->clearUnreads();
$this->pack($message);
$this->deliver();

Loading…
Cancel
Save