Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
UserNotificationPrefs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
29 | |
100.00% |
1 / 1 |
setUserId | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getUserId | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setTransport | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getTransport | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setTargetGSActorId | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getTargetGSActorId | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setActivityByFollowed | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getActivityByFollowed | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setMention | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getMention | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setReply | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getReply | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setFollow | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getFollow | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setFavorite | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getFavorite | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setNudge | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getNudge | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setDm | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getDm | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setPostOnStatusChange | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getPostOnStatusChange | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setEnablePosting | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getEnablePosting | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setCreated | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getCreated | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setModified | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getModified | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
schemaDef | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
1 | <?php |
2 | |
3 | // {{{ License |
4 | // This file is part of GNU social - https://www.gnu.org/software/social |
5 | // |
6 | // GNU social is free software: you can redistribute it and/or modify |
7 | // it under the terms of the GNU Affero General Public License as published by |
8 | // the Free Software Foundation, either version 3 of the License, or |
9 | // (at your option) any later version. |
10 | // |
11 | // GNU social is distributed in the hope that it will be useful, |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | // GNU Affero General Public License for more details. |
15 | // |
16 | // You should have received a copy of the GNU Affero General Public License |
17 | // along with GNU social. If not, see <http://www.gnu.org/licenses/>. |
18 | // }}} |
19 | |
20 | namespace App\Entity; |
21 | |
22 | use App\Core\Entity; |
23 | use DateTimeInterface; |
24 | |
25 | /** |
26 | * Entity for user notification preferences |
27 | * |
28 | * @category DB |
29 | * @package GNUsocial |
30 | * |
31 | * @author Hugo Sales <hugo@hsal.es> |
32 | * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org |
33 | * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later |
34 | */ |
35 | class UserNotificationPrefs extends Entity |
36 | { |
37 | // {{{ Autocode |
38 | // @codeCoverageIgnoreStart |
39 | private int $user_id; |
40 | private string $transport; |
41 | private ?int $target_gsactor_id; |
42 | private bool $activity_by_followed = true; |
43 | private bool $mention = true; |
44 | private bool $reply = true; |
45 | private bool $follow = true; |
46 | private bool $favorite = true; |
47 | private bool $nudge = false; |
48 | private bool $dm = true; |
49 | private bool $post_on_status_change = false; |
50 | private ?bool $enable_posting; |
51 | private \DateTimeInterface $created; |
52 | private \DateTimeInterface $modified; |
53 | |
54 | public function setUserId(int $user_id): self |
55 | { |
56 | $this->user_id = $user_id; |
57 | return $this; |
58 | } |
59 | |
60 | public function getUserId(): int |
61 | { |
62 | return $this->user_id; |
63 | } |
64 | |
65 | public function setTransport(string $transport): self |
66 | { |
67 | $this->transport = $transport; |
68 | return $this; |
69 | } |
70 | |
71 | public function getTransport(): string |
72 | { |
73 | return $this->transport; |
74 | } |
75 | |
76 | public function setTargetGSActorId(?int $target_gsactor_id): self |
77 | { |
78 | $this->target_gsactor_id = $target_gsactor_id; |
79 | return $this; |
80 | } |
81 | |
82 | public function getTargetGSActorId(): ?int |
83 | { |
84 | return $this->target_gsactor_id; |
85 | } |
86 | |
87 | public function setActivityByFollowed(bool $activity_by_followed): self |
88 | { |
89 | $this->activity_by_followed = $activity_by_followed; |
90 | return $this; |
91 | } |
92 | |
93 | public function getActivityByFollowed(): bool |
94 | { |
95 | return $this->activity_by_followed; |
96 | } |
97 | |
98 | public function setMention(bool $mention): self |
99 | { |
100 | $this->mention = $mention; |
101 | return $this; |
102 | } |
103 | |
104 | public function getMention(): bool |
105 | { |
106 | return $this->mention; |
107 | } |
108 | |
109 | public function setReply(bool $reply): self |
110 | { |
111 | $this->reply = $reply; |
112 | return $this; |
113 | } |
114 | |
115 | public function getReply(): bool |
116 | { |
117 | return $this->reply; |
118 | } |
119 | |
120 | public function setFollow(bool $follow): self |
121 | { |
122 | $this->follow = $follow; |
123 | return $this; |
124 | } |
125 | |
126 | public function getFollow(): bool |
127 | { |
128 | return $this->follow; |
129 | } |
130 | |
131 | public function setFavorite(bool $favorite): self |
132 | { |
133 | $this->favorite = $favorite; |
134 | return $this; |
135 | } |
136 | |
137 | public function getFavorite(): bool |
138 | { |
139 | return $this->favorite; |
140 | } |
141 | |
142 | public function setNudge(bool $nudge): self |
143 | { |
144 | $this->nudge = $nudge; |
145 | return $this; |
146 | } |
147 | |
148 | public function getNudge(): bool |
149 | { |
150 | return $this->nudge; |
151 | } |
152 | |
153 | public function setDm(bool $dm): self |
154 | { |
155 | $this->dm = $dm; |
156 | return $this; |
157 | } |
158 | |
159 | public function getDm(): bool |
160 | { |
161 | return $this->dm; |
162 | } |
163 | |
164 | public function setPostOnStatusChange(bool $post_on_status_change): self |
165 | { |
166 | $this->post_on_status_change = $post_on_status_change; |
167 | return $this; |
168 | } |
169 | |
170 | public function getPostOnStatusChange(): bool |
171 | { |
172 | return $this->post_on_status_change; |
173 | } |
174 | |
175 | public function setEnablePosting(?bool $enable_posting): self |
176 | { |
177 | $this->enable_posting = $enable_posting; |
178 | return $this; |
179 | } |
180 | |
181 | public function getEnablePosting(): ?bool |
182 | { |
183 | return $this->enable_posting; |
184 | } |
185 | |
186 | public function setCreated(DateTimeInterface $created): self |
187 | { |
188 | $this->created = $created; |
189 | return $this; |
190 | } |
191 | |
192 | public function getCreated(): DateTimeInterface |
193 | { |
194 | return $this->created; |
195 | } |
196 | |
197 | public function setModified(DateTimeInterface $modified): self |
198 | { |
199 | $this->modified = $modified; |
200 | return $this; |
201 | } |
202 | |
203 | public function getModified(): DateTimeInterface |
204 | { |
205 | return $this->modified; |
206 | } |
207 | |
208 | // @codeCoverageIgnoreEnd |
209 | // }}} Autocode |
210 | |
211 | public static function schemaDef(): array |
212 | { |
213 | return [ |
214 | 'name' => 'user_notification_prefs', |
215 | 'fields' => [ |
216 | 'user_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'LocalUser.id', 'multiplicity' => 'one to one', 'not null' => true], |
217 | 'transport' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'transport (ex email. xmpp, aim)'], |
218 | 'target_gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'default' => null, 'description' => 'If not null, settings are specific only to a given gsactors'], |
219 | 'activity_by_followed' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when a new activity by someone we follow is made'], |
220 | 'mention' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when mentioned by someone we do not follow'], |
221 | 'reply' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when someone replies to a notice made by us'], |
222 | 'follow' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify someone follows us'], |
223 | 'favorite' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify someone favorites a notice by us'], |
224 | 'nudge' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Notify someone nudges us'], |
225 | 'dm' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify someone sends us a direct message'], |
226 | 'post_on_status_change' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Post a notice when our status in service changes'], |
227 | 'enable_posting' => ['type' => 'bool', 'default' => true, 'description' => 'Enable posting from this service'], |
228 | 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], |
229 | 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], |
230 | ], |
231 | 'primary key' => ['user_id', 'transport'], |
232 | 'indexes' => [ |
233 | 'user_notification_prefs_user_target_gsactor_idx' => ['user_id', 'target_gsactor_id'], |
234 | ], |
235 | ]; |
236 | } |
237 | } |