diff options
Diffstat (limited to 'server/models/account/account-video-rate.ts')
-rw-r--r-- | server/models/account/account-video-rate.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts index 85af9e378..d5c214ecb 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/models/account/account-video-rate.ts | |||
@@ -89,6 +89,25 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> { | |||
89 | return AccountVideoRateModel.findOne(options) | 89 | return AccountVideoRateModel.findOne(options) |
90 | } | 90 | } |
91 | 91 | ||
92 | static loadByAccountAndVideoOrUrl (accountId: number, videoId: number, url: string, transaction?: Transaction) { | ||
93 | const options: FindOptions = { | ||
94 | where: { | ||
95 | [ Op.or]: [ | ||
96 | { | ||
97 | accountId, | ||
98 | videoId | ||
99 | }, | ||
100 | { | ||
101 | url | ||
102 | } | ||
103 | ] | ||
104 | } | ||
105 | } | ||
106 | if (transaction) options.transaction = transaction | ||
107 | |||
108 | return AccountVideoRateModel.findOne(options) | ||
109 | } | ||
110 | |||
92 | static listByAccountForApi (options: { | 111 | static listByAccountForApi (options: { |
93 | start: number, | 112 | start: number, |
94 | count: number, | 113 | count: number, |
@@ -202,6 +221,23 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> { | |||
202 | videoId, | 221 | videoId, |
203 | type | 222 | type |
204 | }, | 223 | }, |
224 | include: [ | ||
225 | { | ||
226 | model: AccountModel.unscoped(), | ||
227 | required: true, | ||
228 | include: [ | ||
229 | { | ||
230 | model: ActorModel.unscoped(), | ||
231 | required: true, | ||
232 | where: { | ||
233 | serverId: { | ||
234 | [Op.ne]: null | ||
235 | } | ||
236 | } | ||
237 | } | ||
238 | ] | ||
239 | } | ||
240 | ], | ||
205 | transaction: t | 241 | transaction: t |
206 | } | 242 | } |
207 | 243 | ||