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-09-22 16:33:40 +0300
committerJoas Schilling <coding@schilljs.com>2020-09-22 16:33:40 +0300
commitef34d96ff03cd064850bea11ee507ef448dd2074 (patch)
tree30bf8fa7fbe90e444a9760edf5a49e5f93ad38e6 /lib/MatterbridgeManager.php
parentfb12c7378b53519b6fea8a06c89a6062d1af25f8 (diff)
Loop over the enabled bridges instead of all rooms
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/MatterbridgeManager.php')
-rw-r--r--lib/MatterbridgeManager.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/MatterbridgeManager.php b/lib/MatterbridgeManager.php
index 16c6b8cd5..6ae5b2d25 100644
--- a/lib/MatterbridgeManager.php
+++ b/lib/MatterbridgeManager.php
@@ -190,21 +190,32 @@ class MatterbridgeManager {
* For each room, check mattermost process respects desired state
*/
public function checkAllBridges(): void {
- // TODO call this from time to time to make sure everything is running fine
- $this->manager->forAllRooms(function ($room) {
- if ($room->getType() === Room::GROUP_CALL || $room->getType() === Room::PUBLIC_CALL) {
- $this->checkBridge($room);
+ $query = $this->db->getQueryBuilder();
+ $query->select('*')
+ ->from('talk_bridges')
+ ->where($query->expr()->like('json_values', $query->createNamedParameter(
+ $this->db->escapeLikeParameter('{"enabled":true') . '%'
+ )));
+
+ $result = $query->execute();
+ while ($row = $result->fetch()) {
+ $bridge = json_decode($row['json_values'], true);
+ if ($bridge['enabled']) {
+ $room = $this->manager->getRoomById((int) $row['room_id']);
+ $this->checkBridge($room, $bridge);
}
- });
+ }
+ $result->closeCursor();
}
/**
* For one room, check mattermost process respects desired state
* @param Room $room the room
+ * @param array|null $bridge
* @return int the bridge process ID
*/
- public function checkBridge(Room $room): int {
- $bridge = $this->getBridgeOfRoom($room);
+ public function checkBridge(Room $room, ?array $bridge = null): int {
+ $bridge = $bridge ?: $this->getBridgeOfRoom($room);
$pid = $this->checkBridgeProcess($room, $bridge);
if ($pid !== $bridge['pid']) {
// save the new PID if necessary