diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-23 09:50:57 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:26:21 +0200 |
commit | 3acc50844047a37698f0618fa235c138e386a053 (patch) | |
tree | e33243bf7fadbcf2df616fc41814245094fd881a /server/models/account/user-notification.ts | |
parent | 1735c825726edaa0af5035cb6cbb0cc0db502c6d (diff) | |
download | PeerTube-3acc50844047a37698f0618fa235c138e386a053.tar.gz PeerTube-3acc50844047a37698f0618fa235c138e386a053.tar.zst PeerTube-3acc50844047a37698f0618fa235c138e386a053.zip |
Upgrade sequelize
Diffstat (limited to 'server/models/account/user-notification.ts')
-rw-r--r-- | server/models/account/user-notification.ts | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/server/models/account/user-notification.ts b/server/models/account/user-notification.ts index 08388f268..a4f97037b 100644 --- a/server/models/account/user-notification.ts +++ b/server/models/account/user-notification.ts | |||
@@ -6,7 +6,7 @@ import { isUserNotificationTypeValid } from '../../helpers/custom-validators/use | |||
6 | import { UserModel } from './user' | 6 | import { UserModel } from './user' |
7 | import { VideoModel } from '../video/video' | 7 | import { VideoModel } from '../video/video' |
8 | import { VideoCommentModel } from '../video/video-comment' | 8 | import { VideoCommentModel } from '../video/video-comment' |
9 | import { FindOptions, Op } from 'sequelize' | 9 | import { FindOptions, ModelIndexesOptions, Op, WhereOptions } from 'sequelize' |
10 | import { VideoChannelModel } from '../video/video-channel' | 10 | import { VideoChannelModel } from '../video/video-channel' |
11 | import { AccountModel } from './account' | 11 | import { AccountModel } from './account' |
12 | import { VideoAbuseModel } from '../video/video-abuse' | 12 | import { VideoAbuseModel } from '../video/video-abuse' |
@@ -24,17 +24,17 @@ enum ScopeNames { | |||
24 | function buildActorWithAvatarInclude () { | 24 | function buildActorWithAvatarInclude () { |
25 | return { | 25 | return { |
26 | attributes: [ 'preferredUsername' ], | 26 | attributes: [ 'preferredUsername' ], |
27 | model: () => ActorModel.unscoped(), | 27 | model: ActorModel.unscoped(), |
28 | required: true, | 28 | required: true, |
29 | include: [ | 29 | include: [ |
30 | { | 30 | { |
31 | attributes: [ 'filename' ], | 31 | attributes: [ 'filename' ], |
32 | model: () => AvatarModel.unscoped(), | 32 | model: AvatarModel.unscoped(), |
33 | required: false | 33 | required: false |
34 | }, | 34 | }, |
35 | { | 35 | { |
36 | attributes: [ 'host' ], | 36 | attributes: [ 'host' ], |
37 | model: () => ServerModel.unscoped(), | 37 | model: ServerModel.unscoped(), |
38 | required: false | 38 | required: false |
39 | } | 39 | } |
40 | ] | 40 | ] |
@@ -44,7 +44,7 @@ function buildActorWithAvatarInclude () { | |||
44 | function buildVideoInclude (required: boolean) { | 44 | function buildVideoInclude (required: boolean) { |
45 | return { | 45 | return { |
46 | attributes: [ 'id', 'uuid', 'name' ], | 46 | attributes: [ 'id', 'uuid', 'name' ], |
47 | model: () => VideoModel.unscoped(), | 47 | model: VideoModel.unscoped(), |
48 | required | 48 | required |
49 | } | 49 | } |
50 | } | 50 | } |
@@ -53,7 +53,7 @@ function buildChannelInclude (required: boolean, withActor = false) { | |||
53 | return { | 53 | return { |
54 | required, | 54 | required, |
55 | attributes: [ 'id', 'name' ], | 55 | attributes: [ 'id', 'name' ], |
56 | model: () => VideoChannelModel.unscoped(), | 56 | model: VideoChannelModel.unscoped(), |
57 | include: withActor === true ? [ buildActorWithAvatarInclude() ] : [] | 57 | include: withActor === true ? [ buildActorWithAvatarInclude() ] : [] |
58 | } | 58 | } |
59 | } | 59 | } |
@@ -62,12 +62,12 @@ function buildAccountInclude (required: boolean, withActor = false) { | |||
62 | return { | 62 | return { |
63 | required, | 63 | required, |
64 | attributes: [ 'id', 'name' ], | 64 | attributes: [ 'id', 'name' ], |
65 | model: () => AccountModel.unscoped(), | 65 | model: AccountModel.unscoped(), |
66 | include: withActor === true ? [ buildActorWithAvatarInclude() ] : [] | 66 | include: withActor === true ? [ buildActorWithAvatarInclude() ] : [] |
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | @Scopes({ | 70 | @Scopes(() => ({ |
71 | [ScopeNames.WITH_ALL]: { | 71 | [ScopeNames.WITH_ALL]: { |
72 | include: [ | 72 | include: [ |
73 | Object.assign(buildVideoInclude(false), { | 73 | Object.assign(buildVideoInclude(false), { |
@@ -76,7 +76,7 @@ function buildAccountInclude (required: boolean, withActor = false) { | |||
76 | 76 | ||
77 | { | 77 | { |
78 | attributes: [ 'id', 'originCommentId' ], | 78 | attributes: [ 'id', 'originCommentId' ], |
79 | model: () => VideoCommentModel.unscoped(), | 79 | model: VideoCommentModel.unscoped(), |
80 | required: false, | 80 | required: false, |
81 | include: [ | 81 | include: [ |
82 | buildAccountInclude(true, true), | 82 | buildAccountInclude(true, true), |
@@ -86,56 +86,56 @@ function buildAccountInclude (required: boolean, withActor = false) { | |||
86 | 86 | ||
87 | { | 87 | { |
88 | attributes: [ 'id' ], | 88 | attributes: [ 'id' ], |
89 | model: () => VideoAbuseModel.unscoped(), | 89 | model: VideoAbuseModel.unscoped(), |
90 | required: false, | 90 | required: false, |
91 | include: [ buildVideoInclude(true) ] | 91 | include: [ buildVideoInclude(true) ] |
92 | }, | 92 | }, |
93 | 93 | ||
94 | { | 94 | { |
95 | attributes: [ 'id' ], | 95 | attributes: [ 'id' ], |
96 | model: () => VideoBlacklistModel.unscoped(), | 96 | model: VideoBlacklistModel.unscoped(), |
97 | required: false, | 97 | required: false, |
98 | include: [ buildVideoInclude(true) ] | 98 | include: [ buildVideoInclude(true) ] |
99 | }, | 99 | }, |
100 | 100 | ||
101 | { | 101 | { |
102 | attributes: [ 'id', 'magnetUri', 'targetUrl', 'torrentName' ], | 102 | attributes: [ 'id', 'magnetUri', 'targetUrl', 'torrentName' ], |
103 | model: () => VideoImportModel.unscoped(), | 103 | model: VideoImportModel.unscoped(), |
104 | required: false, | 104 | required: false, |
105 | include: [ buildVideoInclude(false) ] | 105 | include: [ buildVideoInclude(false) ] |
106 | }, | 106 | }, |
107 | 107 | ||
108 | { | 108 | { |
109 | attributes: [ 'id', 'state' ], | 109 | attributes: [ 'id', 'state' ], |
110 | model: () => ActorFollowModel.unscoped(), | 110 | model: ActorFollowModel.unscoped(), |
111 | required: false, | 111 | required: false, |
112 | include: [ | 112 | include: [ |
113 | { | 113 | { |
114 | attributes: [ 'preferredUsername' ], | 114 | attributes: [ 'preferredUsername' ], |
115 | model: () => ActorModel.unscoped(), | 115 | model: ActorModel.unscoped(), |
116 | required: true, | 116 | required: true, |
117 | as: 'ActorFollower', | 117 | as: 'ActorFollower', |
118 | include: [ | 118 | include: [ |
119 | { | 119 | { |
120 | attributes: [ 'id', 'name' ], | 120 | attributes: [ 'id', 'name' ], |
121 | model: () => AccountModel.unscoped(), | 121 | model: AccountModel.unscoped(), |
122 | required: true | 122 | required: true |
123 | }, | 123 | }, |
124 | { | 124 | { |
125 | attributes: [ 'filename' ], | 125 | attributes: [ 'filename' ], |
126 | model: () => AvatarModel.unscoped(), | 126 | model: AvatarModel.unscoped(), |
127 | required: false | 127 | required: false |
128 | }, | 128 | }, |
129 | { | 129 | { |
130 | attributes: [ 'host' ], | 130 | attributes: [ 'host' ], |
131 | model: () => ServerModel.unscoped(), | 131 | model: ServerModel.unscoped(), |
132 | required: false | 132 | required: false |
133 | } | 133 | } |
134 | ] | 134 | ] |
135 | }, | 135 | }, |
136 | { | 136 | { |
137 | attributes: [ 'preferredUsername' ], | 137 | attributes: [ 'preferredUsername' ], |
138 | model: () => ActorModel.unscoped(), | 138 | model: ActorModel.unscoped(), |
139 | required: true, | 139 | required: true, |
140 | as: 'ActorFollowing', | 140 | as: 'ActorFollowing', |
141 | include: [ | 141 | include: [ |
@@ -147,9 +147,9 @@ function buildAccountInclude (required: boolean, withActor = false) { | |||
147 | }, | 147 | }, |
148 | 148 | ||
149 | buildAccountInclude(false, true) | 149 | buildAccountInclude(false, true) |
150 | ] as any // FIXME: sequelize typings | 150 | ] |
151 | } | 151 | } |
152 | }) | 152 | })) |
153 | @Table({ | 153 | @Table({ |
154 | tableName: 'userNotification', | 154 | tableName: 'userNotification', |
155 | indexes: [ | 155 | indexes: [ |
@@ -212,7 +212,7 @@ function buildAccountInclude (required: boolean, withActor = false) { | |||
212 | } | 212 | } |
213 | } | 213 | } |
214 | } | 214 | } |
215 | ] as any // FIXME: sequelize typings | 215 | ] as (ModelIndexesOptions & { where?: WhereOptions })[] |
216 | }) | 216 | }) |
217 | export class UserNotificationModel extends Model<UserNotificationModel> { | 217 | export class UserNotificationModel extends Model<UserNotificationModel> { |
218 | 218 | ||
@@ -357,7 +357,7 @@ export class UserNotificationModel extends Model<UserNotificationModel> { | |||
357 | where: { | 357 | where: { |
358 | userId, | 358 | userId, |
359 | id: { | 359 | id: { |
360 | [Op.any]: notificationIds | 360 | [Op.in]: notificationIds // FIXME: sequelize ANY seems broken |
361 | } | 361 | } |
362 | } | 362 | } |
363 | } | 363 | } |