1<?php 2 3declare(strict_types=1); 4/** 5 * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com> 6 * 7 * @license GNU AGPL version 3 or any later version 8 * 9 * This program is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU Affero General Public License as 11 * published by the Free Software Foundation, either version 3 of the 12 * License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Affero General Public License for more details. 18 * 19 * You should have received a copy of the GNU Affero General Public License 20 * along with this program. If not, see <http://www.gnu.org/licenses/>. 21 * 22 */ 23 24namespace OCA\Talk\Model; 25 26use OCP\AppFramework\Db\Entity; 27 28/** 29 * @method void setRoomId(int $roomId) 30 * @method int getRoomId() 31 * @method void setActorType(string $actorType) 32 * @method string getActorType() 33 * @method void setActorId(string $actorId) 34 * @method string getActorId() 35 * @method void setDisplayName(string $displayName) 36 * @method void setPin(string $pin) 37 * @method null|string getPin() 38 * @method void setParticipantType(int $participantType) 39 * @method int getParticipantType() 40 * @method void setFavorite(bool $favorite) 41 * @method bool isFavorite() 42 * @method void setNotificationLevel(int $notificationLevel) 43 * @method int getNotificationLevel() 44 * @method void setNotificationCalls(int $notificationCalls) 45 * @method int getNotificationCalls() 46 * @method void setLastJoinedCall(int $lastJoinedCall) 47 * @method int getLastJoinedCall() 48 * @method void setLastReadMessage(int $lastReadMessage) 49 * @method int getLastReadMessage() 50 * @method void setLastMentionMessage(int $lastMentionMessage) 51 * @method int getLastMentionMessage() 52 * @method void setLastMentionDirect(int $lastMentionDirect) 53 * @method int getLastMentionDirect() 54 * @method void setReadPrivacy(int $readPrivacy) 55 * @method int getReadPrivacy() 56 * @method void setPermissions(int $permissions) 57 * @internal 58 * @method int getPermissions() 59 * @method void setAccessToken(string $accessToken) 60 * @method null|string getAccessToken() 61 * @method void setRemoteId(string $remoteId) 62 * @method string getRemoteId() 63 */ 64class Attendee extends Entity { 65 public const ACTOR_USERS = 'users'; 66 public const ACTOR_GROUPS = 'groups'; 67 public const ACTOR_GUESTS = 'guests'; 68 public const ACTOR_EMAILS = 'emails'; 69 public const ACTOR_CIRCLES = 'circles'; 70 public const ACTOR_BRIDGED = 'bridged'; 71 public const ACTOR_FEDERATED_USERS = 'federated_users'; 72 73 public const PERMISSIONS_DEFAULT = 0; 74 public const PERMISSIONS_CUSTOM = 1; 75 public const PERMISSIONS_CALL_START = 2; 76 public const PERMISSIONS_CALL_JOIN = 4; 77 public const PERMISSIONS_LOBBY_IGNORE = 8; 78 public const PERMISSIONS_PUBLISH_AUDIO = 16; 79 public const PERMISSIONS_PUBLISH_VIDEO = 32; 80 public const PERMISSIONS_PUBLISH_SCREEN = 64; 81 public const PERMISSIONS_MAX_DEFAULT = // Max int (when all permissions are granted as default) 82 self::PERMISSIONS_CALL_START 83 | self::PERMISSIONS_CALL_JOIN 84 | self::PERMISSIONS_LOBBY_IGNORE 85 | self::PERMISSIONS_PUBLISH_AUDIO 86 | self::PERMISSIONS_PUBLISH_VIDEO 87 | self::PERMISSIONS_PUBLISH_SCREEN 88 ; 89 public const PERMISSIONS_MAX_CUSTOM = self::PERMISSIONS_MAX_DEFAULT | self::PERMISSIONS_CUSTOM; // Max int (when all permissions are granted as custom) 90 91 public const PERMISSIONS_MODIFY_SET = 'set'; 92 public const PERMISSIONS_MODIFY_REMOVE = 'remove'; 93 public const PERMISSIONS_MODIFY_ADD = 'add'; 94 95 /** @var int */ 96 protected $roomId; 97 98 /** @var string */ 99 protected $actorType; 100 101 /** @var string */ 102 protected $actorId; 103 104 /** @var null|string */ 105 protected $displayName; 106 107 /** @var null|string */ 108 protected $pin; 109 110 /** @var int */ 111 protected $participantType; 112 113 /** @var bool */ 114 protected $favorite; 115 116 /** @var int */ 117 protected $notificationLevel; 118 119 /** @var int */ 120 protected $notificationCalls; 121 122 /** @var int */ 123 protected $lastJoinedCall; 124 125 /** @var int */ 126 protected $lastReadMessage; 127 128 /** @var int */ 129 protected $lastMentionMessage; 130 131 /** @var int */ 132 protected $lastMentionDirect; 133 134 /** @var int */ 135 protected $readPrivacy; 136 137 /** @var int */ 138 protected $permissions; 139 140 /** @var string */ 141 protected $accessToken; 142 143 /** @var string */ 144 protected $remoteId; 145 146 public function __construct() { 147 $this->addType('roomId', 'int'); 148 $this->addType('actorType', 'string'); 149 $this->addType('actorId', 'string'); 150 $this->addType('displayName', 'string'); 151 $this->addType('pin', 'string'); 152 $this->addType('participantType', 'int'); 153 $this->addType('favorite', 'bool'); 154 $this->addType('notificationLevel', 'int'); 155 $this->addType('notificationCalls', 'int'); 156 $this->addType('lastJoinedCall', 'int'); 157 $this->addType('lastReadMessage', 'int'); 158 $this->addType('lastMentionMessage', 'int'); 159 $this->addType('lastMentionDirect', 'int'); 160 $this->addType('readPrivacy', 'int'); 161 $this->addType('permissions', 'int'); 162 $this->addType('accessToken', 'string'); 163 $this->addType('remote_id', 'string'); 164 } 165 166 public function getDisplayName(): string { 167 return (string) $this->displayName; 168 } 169 170 /** 171 * @return array 172 */ 173 public function asArray(): array { 174 return [ 175 'id' => $this->getId(), 176 'room_id' => $this->getRoomId(), 177 'actor_type' => $this->getActorType(), 178 'actor_id' => $this->getActorId(), 179 'display_name' => $this->getDisplayName(), 180 'pin' => $this->getPin(), 181 'participant_type' => $this->getParticipantType(), 182 'favorite' => $this->isFavorite(), 183 'notification_level' => $this->getNotificationLevel(), 184 'notification_calls' => $this->getNotificationCalls(), 185 'last_joined_call' => $this->getLastJoinedCall(), 186 'last_read_message' => $this->getLastReadMessage(), 187 'last_mention_message' => $this->getLastMentionMessage(), 188 'last_mention_direct' => $this->getLastMentionDirect(), 189 'read_privacy' => $this->getReadPrivacy(), 190 'permissions' => $this->getPermissions(), 191 'access_token' => $this->getAccessToken(), 192 'remote_id' => $this->getRemoteId(), 193 ]; 194 } 195} 196