|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ownCloud - Music app |
|
5
|
|
|
* |
|
6
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
7
|
|
|
* later. See the COPYING file. |
|
8
|
|
|
* |
|
9
|
|
|
* @author Gavin E <[email protected]> |
|
10
|
|
|
* @author Pauli Järvinen <[email protected]> |
|
11
|
|
|
* @copyright Gavin E 2020 |
|
12
|
|
|
* @copyright Pauli Järvinen 2020, 2021 |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace OCA\Music\Db; |
|
16
|
|
|
|
|
17
|
|
|
use \OCA\Music\Utility\Util; |
|
18
|
|
|
use \OCP\AppFramework\Db\Entity; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @method string getUserId() |
|
22
|
|
|
* @method void setUserId(string $userId) |
|
23
|
|
|
* @method int getType() |
|
24
|
|
|
* @method void setType(int $type) |
|
25
|
|
|
* @method int getEntryId() |
|
26
|
|
|
* @method void setEntryId(int $entryId) |
|
27
|
|
|
* @method int getPosition() |
|
28
|
|
|
* @method void setPosition(int $position) |
|
29
|
|
|
* @method ?string getComment() |
|
30
|
|
|
* @method void setComment(?string $comment) |
|
31
|
|
|
* @method ?string getCreated() |
|
32
|
|
|
* @method setCreated(?string $timestamp) |
|
33
|
|
|
* @method ?string getUpdated() |
|
34
|
|
|
* @method setUpdated(?string $timestamp) |
|
35
|
|
|
*/ |
|
36
|
|
|
class Bookmark extends Entity { |
|
37
|
|
|
public $userId; |
|
38
|
|
|
public $type; |
|
39
|
|
|
public $entryId; |
|
40
|
|
|
public $position; |
|
41
|
|
|
public $comment; |
|
42
|
|
|
public $created; |
|
43
|
|
|
public $updated; |
|
44
|
|
|
|
|
45
|
|
|
public const TYPE_TRACK = 1; |
|
46
|
|
|
public const TYPE_PODCAST_EPISODE = 2; |
|
47
|
|
|
|
|
48
|
|
|
public function __construct() { |
|
49
|
|
|
$this->addType('type', 'int'); |
|
50
|
|
|
$this->addType('entryId', 'int'); |
|
51
|
|
|
$this->addType('position', 'int'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function toSubsonicApi() : array { |
|
55
|
|
|
return [ |
|
56
|
|
|
'position' => $this->getPosition(), |
|
57
|
|
|
'username' => $this->userId, |
|
58
|
|
|
'comment' => $this->getComment() ?: '', |
|
59
|
|
|
'created' => Util::formatZuluDateTime($this->getCreated()), |
|
60
|
|
|
'changed' => Util::formatZuluDateTime($this->getUpdated()) |
|
61
|
|
|
]; |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|