Skip to content

Commit

Permalink
Merge pull request #1599 from nextcloud/backport/1581/duplicated-call…
Browse files Browse the repository at this point in the history
…-summary-message

[stable15] Fix duplicated call summary message when multiple people leave at the…
  • Loading branch information
nickvergessen authored Mar 7, 2019
2 parents d415915 + 1c2a8d8 commit d9848f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 9 additions & 3 deletions lib/Activity/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ public function generateCallActivity(Room $room): bool {
return false;
}

$numGuests = $room->getActiveGuests();

if (!$room->resetActiveSince()) {
// Race-condition, the room was already reset.
return false;
}

$event = $this->activityManager->generateEvent();
try {
$event->setApp('spreed')
Expand All @@ -95,7 +102,7 @@ public function generateCallActivity(Room $room): bool {
->setSubject('call', [
'room' => $room->getId(),
'users' => $userIds,
'guests' => $room->getActiveGuests(),
'guests' => $numGuests,
'duration' => $duration,
]);
} catch (\InvalidArgumentException $e) {
Expand All @@ -107,7 +114,7 @@ public function generateCallActivity(Room $room): bool {
'message' => 'call_ended',
'parameters' => [
'users' => $userIds,
'guests' => $room->getActiveGuests(),
'guests' => $numGuests,
'duration' => $duration,
],
]), new \DateTime(), false);
Expand All @@ -123,7 +130,6 @@ public function generateCallActivity(Room $room): bool {
}
}

$room->resetActiveSince();
return true;
}

Expand Down
6 changes: 5 additions & 1 deletion lib/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,11 @@ public function resetActiveSince() {
->set('active_guests', $query->createNamedParameter(0))
->set('active_since', $query->createNamedParameter(null, 'datetime'))
->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)));
$query->execute();

$this->activeGuests = 0;
$this->activeSince = null;

return (bool) $query->execute();
}

/**
Expand Down

0 comments on commit d9848f5

Please sign in to comment.