diff options
author | Joas Schilling <coding@schilljs.com> | 2018-03-26 19:24:39 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-03-27 18:16:38 +0300 |
commit | 3ec66a20449b4ec00e960fce1046ffa8e8702f51 (patch) | |
tree | 501c2fc3baa316b10faa6422c3dc838878b8f43e /lib/TalkSession.php | |
parent | b314bd0ae4a3a60a50d2657c86820642657a4d5e (diff) |
Abstract away the session handling
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/TalkSession.php')
-rw-r--r-- | lib/TalkSession.php | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/lib/TalkSession.php b/lib/TalkSession.php new file mode 100644 index 000000000..172774f10 --- /dev/null +++ b/lib/TalkSession.php @@ -0,0 +1,84 @@ +<?php +/** + * @copyright Copyright (c) 2018 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\Spreed; + + +use OCP\ISession; + +class TalkSession { + + /** @var ISession */ + protected $session; + + public function __construct(ISession $session) { + $this->session = $session; + } + + /** + * @param string $token + * @return string|null + */ + public function getSessionForRoom($token) { + return $this->session->get('spreed-session'); + } + + /** + * @param string $token + * @param string $sessionId + */ + public function setSessionForRoom($token, $sessionId) { + $this->session->set('spreed-session', $sessionId); + } + + /** + * @param string $token + */ + public function removeSessionForRoom($token) { + $this->session->remove('spreed-session'); + } + + /** + * @param string $token + * @return string|null + */ + public function getPasswordForRoom($token) { + return $this->session->get('spreed-password'); + } + + /** + * @param string $token + * @param string $password + * @return string|null + */ + public function setPasswordForRoom($token, $password) { + $this->session->set('spreed-password', $password); + } + + /** + * @param string $token + */ + public function removePasswordForRoom($token) { + $this->session->remove('spreed-password'); + } + + +} |