Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-07-09 11:44:57 +0300
committerJoas Schilling <coding@schilljs.com>2021-07-09 11:44:57 +0300
commit9e855fc015fce36108d68dc13f595cedd42d80dc (patch)
treeabad829323f6fd1fcd58cddb5a910523637b949c /lib
parent5df729fe472a6dd676f6d4cae7c9cc67fb400e5c (diff)
Add "missed call" notifications
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Activity/Listener.php12
-rw-r--r--lib/Chat/Parser/SystemMessage.php30
2 files changed, 38 insertions, 4 deletions
diff --git a/lib/Activity/Listener.php b/lib/Activity/Listener.php
index 5e62e3c0c..108351690 100644
--- a/lib/Activity/Listener.php
+++ b/lib/Activity/Listener.php
@@ -122,10 +122,14 @@ class Listener {
$userIds = $this->participantService->getParticipantUserIds($room, $activeSince);
$numGuests = $this->participantService->getGuestCount($room, $activeSince);
+ $message = 'call_ended';
if ((\count($userIds) + $numGuests) === 1) {
- // Single user pinged or guests only => no summary/activity
- $room->resetActiveSince();
- return false;
+ if ($room->getType() !== Room::ONE_TO_ONE_CALL) {
+ // Single user pinged or guests only => no summary/activity
+ $room->resetActiveSince();
+ return false;
+ }
+ $message = 'call_missed';
}
if (!$room->resetActiveSince()) {
@@ -136,7 +140,7 @@ class Listener {
$actorId = $userIds[0] ?? 'guests-only';
$actorType = $actorId !== 'guests-only' ? Attendee::ACTOR_USERS : Attendee::ACTOR_GUESTS;
$this->chatManager->addSystemMessage($room, $actorType, $actorId, json_encode([
- 'message' => 'call_ended',
+ 'message' => $message,
'parameters' => [
'users' => $userIds,
'guests' => $numGuests,
diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php
index f3d72a845..00029c2be 100644
--- a/lib/Chat/Parser/SystemMessage.php
+++ b/lib/Chat/Parser/SystemMessage.php
@@ -167,6 +167,8 @@ class SystemMessage {
if ($currentUserIsActor) {
$parsedMessage = $this->l->t('You left the call');
}
+ } elseif ($message === 'call_missed') {
+ [$parsedMessage, $parsedParameters, $message] = $this->parseMissedCall($room, $parameters, $currentActorId);
} elseif ($message === 'call_ended') {
[$parsedMessage, $parsedParameters] = $this->parseCall($parameters);
} elseif ($message === 'read_only_off') {
@@ -624,6 +626,34 @@ class SystemMessage {
}
}
+ protected function parseMissedCall(Room $room, array $parameters, string $currentActorId): array {
+ if ($parameters['users'][0] !== $currentActorId) {
+ return [
+ $this->l->t('You missed a call from {user}'),
+ [
+ 'user' => $this->getUser($parameters['users'][0]),
+ ],
+ 'call_missed',
+ ];
+ }
+
+ $participants = json_decode($room->getName(), true);
+ $other = '';
+ foreach ($participants as $participant) {
+ if ($participant !== $currentActorId) {
+ $other = $participant;
+ }
+ }
+ return [
+ $this->l->t('You tried to call {user}'),
+ [
+ 'user' => $this->getUser($other),
+ ],
+ 'call_tried',
+ ];
+ }
+
+
protected function parseCall(array $parameters): array {
sort($parameters['users']);
$numUsers = \count($parameters['users']);