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/Model
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-10-16 12:26:01 +0300
committerJoas Schilling <coding@schilljs.com>2020-10-30 12:38:08 +0300
commit3c1cb1d9192a1d50c1e991ec9f64ef84181c860b (patch)
treef8686d3705e160a06a37b631a5e0e811f278437f /lib/Model
parenteae9ad72b1b4854897e8e7d4dcdf7d9887ce0e3c (diff)
Remove updating-methods from Participant object
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Model')
-rw-r--r--lib/Model/Attendee.php113
-rw-r--r--lib/Model/AttendeeMapper.php72
-rw-r--r--lib/Model/Session.php71
-rw-r--r--lib/Model/SessionMapper.php64
4 files changed, 320 insertions, 0 deletions
diff --git a/lib/Model/Attendee.php b/lib/Model/Attendee.php
new file mode 100644
index 000000000..6c5690803
--- /dev/null
+++ b/lib/Model/Attendee.php
@@ -0,0 +1,113 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Talk\Model;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method void setRoomId(int $roomId)
+ * @method string getRoomId()
+ * @method void setActorType(string $actorType)
+ * @method string getActorType()
+ * @method void setActorId(string $actorId)
+ * @method string getActorId()
+ * @method void setPin(string $pin)
+ * @method string getPin()
+ * @method void setParticipantType(int $participantType)
+ * @method int getParticipantType()
+ * @method void setFavorite(bool $favorite)
+ * @method bool isFavorite()
+ * @method void setNotificationLevel(int $notificationLevel)
+ * @method int getNotificationLevel()
+ * @method void setLastJoinedCall(int $lastJoinedCall)
+ * @method int getLastJoinedCall()
+ * @method void setLastReadMessage(int $lastReadMessage)
+ * @method int getLastReadMessage()
+ * @method void setLastMentionMessage(int $lastMentionMessage)
+ * @method int getLastMentionMessage()
+ */
+class Attendee extends Entity {
+
+ /** @var int */
+ protected $roomId;
+
+ /** @var string */
+ protected $actorType;
+
+ /** @var string */
+ protected $actorId;
+
+ /** @var string */
+ protected $pin;
+
+ /** @var int */
+ protected $participantType;
+
+ /** @var bool */
+ protected $favorite;
+
+ /** @var int */
+ protected $notificationLevel;
+
+ /** @var int */
+ protected $lastJoinedCall;
+
+ /** @var int */
+ protected $lastReadMessage;
+
+ /** @var int */
+ protected $lastMentionMessage;
+
+ public function __construct() {
+ $this->addType('room_id', 'int');
+ $this->addType('actor_type', 'string');
+ $this->addType('actor_id', 'string');
+ $this->addType('pin', 'string');
+ $this->addType('participant_type', 'int');
+ $this->addType('favorite', 'bool');
+ $this->addType('notification_level', 'int');
+ $this->addType('last_joined_call', 'int');
+ $this->addType('last_read_message', 'int');
+ $this->addType('last_mention_message', 'int');
+ }
+
+ /**
+ * @return array
+ */
+ public function asArray(): array {
+ return [
+ 'id' => $this->getId(),
+ 'room_id' => $this->getRoomId(),
+ 'actor_type' => $this->getActorType(),
+ 'actor_id' => $this->getActorId(),
+ 'pin' => $this->getPin(),
+ 'participant_type' => $this->getParticipantType(),
+ 'favorite' => $this->isFavorite(),
+ 'notification_level' => $this->getNotificationLevel(),
+ 'last_joined_call' => $this->getLastJoinedCall(),
+ 'last_read_message' => $this->getLastReadMessage(),
+ 'last_mention_message' => $this->getLastMentionMessage(),
+ ];
+ }
+}
diff --git a/lib/Model/AttendeeMapper.php b/lib/Model/AttendeeMapper.php
new file mode 100644
index 000000000..4c7e7dcd8
--- /dev/null
+++ b/lib/Model/AttendeeMapper.php
@@ -0,0 +1,72 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Talk\Model;
+
+use OCP\AppFramework\Db\QBMapper;
+use OCP\IDBConnection;
+
+/**
+ * @method Attendee mapRowToEntity(array $row)
+ */
+class AttendeeMapper extends QBMapper {
+
+ /**
+ * @param IDBConnection $db
+ */
+ public function __construct(IDBConnection $db) {
+ parent::__construct($db, 'talk_attendees', Attendee::class);
+ }
+
+ /**
+ * @param string $actorType
+ * @param string $actorId
+ * @return Attendee
+ * @throws \OCP\AppFramework\Db\DoesNotExistException
+ */
+ public function findByActor(string $actorType, string $actorId): Attendee {
+ $query = $this->db->getQueryBuilder();
+ $query->select('*')
+ ->from($this->getTableName())
+ ->where($query->expr()->eq('actor_type', $query->createNamedParameter($actorType)))
+ ->andWhere($query->expr()->eq('actor_id', $query->createNamedParameter($actorId)));
+
+ return $this->findEntity($query);
+ }
+
+ public function createAttendeeFromRow(array $row): Attendee {
+ return $this->mapRowToEntity([
+ 'id' => $row['a_id'],
+ 'room_id' => $row['id'],
+ 'actor_type' => $row['actor_type'],
+ 'actor_id' => $row['actor_id'],
+ 'pin' => $row['pin'],
+ 'participant_type' => (int) $row['participant_type'],
+ 'favorite' => (bool) $row['favorite'],
+ 'notification_level' => (int) $row['notification_level'],
+ 'last_joined_call' => (int) $row['last_joined_call'],
+ 'last_read_message' => (int) $row['last_read_message'],
+ 'last_mention_message' => (int) $row['last_mention_message'],
+ ]);
+ }
+}
diff --git a/lib/Model/Session.php b/lib/Model/Session.php
new file mode 100644
index 000000000..c647e7082
--- /dev/null
+++ b/lib/Model/Session.php
@@ -0,0 +1,71 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Talk\Model;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method void setAttendeeId(int $attendeeId)
+ * @method string getAttendeeId()
+ * @method void setSessionId(string $sessionId)
+ * @method string getSessionId()
+ * @method void setInCall(int $inCall)
+ * @method int getInCall()
+ * @method void setLastPing(int $lastPing)
+ * @method int getLastPing()
+ */
+class Session extends Entity {
+
+ /** @var int */
+ protected $attendeeId;
+
+ /** @var string */
+ protected $sessionId;
+
+ /** @var int */
+ protected $inCall;
+
+ /** @var int */
+ protected $lastPing;
+
+ public function __construct() {
+ $this->addType('attendee_id', 'int');
+ $this->addType('session_id', 'string');
+ $this->addType('in_call', 'int');
+ $this->addType('last_ping', 'int');
+ }
+
+ /**
+ * @return array
+ */
+ public function asArray(): array {
+ return [
+ 'id' => $this->getId(),
+ 'attendee_id' => $this->getAttendeeId(),
+ 'session_id' => $this->getSessionId(),
+ 'in_call' => $this->getInCall(),
+ 'last_ping' => $this->getLastPing(),
+ ];
+ }
+}
diff --git a/lib/Model/SessionMapper.php b/lib/Model/SessionMapper.php
new file mode 100644
index 000000000..c45cafd90
--- /dev/null
+++ b/lib/Model/SessionMapper.php
@@ -0,0 +1,64 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Talk\Model;
+
+use OCP\AppFramework\Db\QBMapper;
+use OCP\IDBConnection;
+
+/**
+ * @method Session mapRowToEntity(array $row)
+ */
+class SessionMapper extends QBMapper {
+
+ /**
+ * @param IDBConnection $db
+ */
+ public function __construct(IDBConnection $db) {
+ parent::__construct($db, 'talk_sessions', Session::class);
+ }
+
+ /**
+ * @param string $sessionId
+ * @return Session
+ * @throws \OCP\AppFramework\Db\DoesNotExistException
+ */
+ public function findBySessionId(string $sessionId): Session {
+ $query = $this->db->getQueryBuilder();
+ $query->select('*')
+ ->from($this->getTableName())
+ ->where($query->expr()->eq('session_id', $query->createNamedParameter($sessionId)));
+
+ return $this->findEntity($query);
+ }
+
+ public function createSessionFromRow(array $row): Session {
+ return $this->mapRowToEntity([
+ 'id' => $row['s_id'],
+ 'session_id' => $row['session_id'],
+ 'attendee_id' => (int) $row['a_id'],
+ 'in_call' => (int) $row['in_call'],
+ 'last_ping' => (int) $row['last_ping'],
+ ]);
+ }
+}