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
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-10-26 17:49:00 +0300
committerJoas Schilling <coding@schilljs.com>2020-10-30 12:38:51 +0300
commita11b907435fdc844a207589d8f8a4cb1583453a5 (patch)
tree2a465ec8b07fef6b4d1b26ef351277fe46fbfdf9 /lib/Service
parent3c61bd47491980e8bd11bb66cf36b354a5212f34 (diff)
Remove last participant modifying functions from Room object
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Service')
-rw-r--r--lib/Service/ParticipantService.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php
index d1075fa0d..ae3580d85 100644
--- a/lib/Service/ParticipantService.php
+++ b/lib/Service/ParticipantService.php
@@ -368,6 +368,16 @@ class ParticipantService {
}
}
+ public function markUsersAsMentioned(Room $room, array $userIds, int $messageId): void {
+ $query = $this->connection->getQueryBuilder();
+ $query->update('talk_attendees')
+ ->set('last_mention_message', $query->createNamedParameter($messageId, IQueryBuilder::PARAM_INT))
+ ->where($query->expr()->eq('room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)))
+ ->andWhere($query->expr()->eq('actor_type', $query->createNamedParameter('users')))
+ ->andWhere($query->expr()->in('actor_id', $query->createNamedParameter($userIds, IQueryBuilder::PARAM_STR_ARRAY)));
+ $query->execute();
+ }
+
/**
* @param Room $room
* @return Participant[]
@@ -527,6 +537,36 @@ class ParticipantService {
/**
* @param Room $room
+ * @return string[]
+ */
+ public function getParticipantUserIdsNotInCall(Room $room): array {
+ $query = $this->connection->getQueryBuilder();
+
+ $query->select('a.actor_id')
+ ->from('talk_sessions', 's')
+ ->leftJoin(
+ 's', 'talk_attendees', 'a',
+ $query->expr()->eq('s.attendee_id', 'a.id')
+ )
+ ->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)))
+ ->andWhere($query->expr()->eq('a.actor_type', $query->createNamedParameter('users')))
+ ->andWhere($query->expr()->orX(
+ $query->expr()->eq('s.in_call', $query->createNamedParameter(Participant::FLAG_DISCONNECTED)),
+ $query->expr()->isNull('s.in_call')
+ ));
+
+ $userIds = [];
+ $result = $query->execute();
+ while ($row = $result->fetch()) {
+ $userIds[] = $row['actor_id'];
+ }
+ $result->closeCursor();
+
+ return $userIds;
+ }
+
+ /**
+ * @param Room $room
* @return int
*/
public function getNumberOfUsers(Room $room): int {
@@ -581,4 +621,26 @@ class ParticipantService {
return (bool) $row;
}
+
+ /**
+ * @param Room $room
+ * @return bool
+ */
+ public function hasActiveSessionsInCall(Room $room): bool {
+ $query = $this->connection->getQueryBuilder();
+ $query->select('a.room_id')
+ ->from('talk_attendees', 'a')
+ ->leftJoin('a', 'talk_sessions', 's', $query->expr()->eq(
+ 'a.id', 's.attendee_id'
+ ))
+ ->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)))
+ ->andWhere($query->expr()->isNotNull('s.in_call'))
+ ->andWhere($query->expr()->neq('s.in_call', $query->createNamedParameter(Participant::FLAG_DISCONNECTED)))
+ ->setMaxResults(1);
+ $result = $query->execute();
+ $row = $result->fetch();
+ $result->closeCursor();
+
+ return (bool) $row;
+ }
}