diff options
author | Joas Schilling <coding@schilljs.com> | 2018-07-13 17:27:34 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-07-13 17:32:49 +0300 |
commit | 1add86b280ce01b94121cb12c0c45d85db2564a9 (patch) | |
tree | dbe990ac6f500a41b5ff07f0ca675e7745c73784 /lib/Participant.php | |
parent | 62b11f9a9f061a164b085e05aaf5ab98f212c057 (diff) |
Handle the favorite on the participant object and fix favorite spelling
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Participant.php')
-rw-r--r-- | lib/Participant.php | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/Participant.php b/lib/Participant.php index 27a2f32a6..1afc48e87 100644 --- a/lib/Participant.php +++ b/lib/Participant.php @@ -23,6 +23,7 @@ namespace OCA\Spreed; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; class Participant { @@ -46,6 +47,8 @@ class Participant { protected $sessionId; /** @var bool */ protected $inCall; + /** @var bool */ + private $isFavorite; /** * @param IDBConnection $db @@ -55,8 +58,9 @@ class Participant { * @param int $lastPing * @param string $sessionId * @param bool $inCall + * @param bool $isFavorite */ - public function __construct(IDBConnection $db, Room $room, $user, $participantType, $lastPing, $sessionId, $inCall) { + public function __construct(IDBConnection $db, Room $room, $user, $participantType, $lastPing, $sessionId, $inCall, $isFavorite) { $this->db = $db; $this->room = $room; $this->user = $user; @@ -64,6 +68,7 @@ class Participant { $this->lastPing = $lastPing; $this->sessionId = $sessionId; $this->inCall = $inCall; + $this->isFavorite = $isFavorite; } public function getUser() { @@ -85,4 +90,27 @@ class Participant { public function isInCall() { return $this->inCall; } + + /** + * @return bool + */ + public function isFavorite() { + return $this->isFavorite; + } + + public function setFavorite($favor) { + if (!$this->user) { + return false; + } + + $query = $this->db->getQueryBuilder(); + $query->update('talk_participants') + ->set('favorite', $query->createNamedParameter((int) $favor, IQueryBuilder::PARAM_INT)) + ->where($query->expr()->eq('user_id', $query->createNamedParameter($this->user))) + ->andWhere($query->expr()->eq('room_id', $query->createNamedParameter($this->room->getId()))); + $query->execute(); + + $this->isFavorite = $favor; + return true; + } } |