aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-channel.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r--server/models/video/video-channel.ts35
1 files changed, 33 insertions, 2 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index c17828f3e..93a611fa0 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -25,6 +25,8 @@ let loadAndPopulateAccount: VideoChannelMethods.LoadAndPopulateAccount
25let loadByUUIDAndPopulateAccount: VideoChannelMethods.LoadByUUIDAndPopulateAccount 25let loadByUUIDAndPopulateAccount: VideoChannelMethods.LoadByUUIDAndPopulateAccount
26let loadByHostAndUUID: VideoChannelMethods.LoadByHostAndUUID 26let loadByHostAndUUID: VideoChannelMethods.LoadByHostAndUUID
27let loadAndPopulateAccountAndVideos: VideoChannelMethods.LoadAndPopulateAccountAndVideos 27let loadAndPopulateAccountAndVideos: VideoChannelMethods.LoadAndPopulateAccountAndVideos
28let loadByUrl: VideoChannelMethods.LoadByUrl
29let loadByUUIDOrUrl: VideoChannelMethods.LoadByUUIDOrUrl
28 30
29export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { 31export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
30 VideoChannel = sequelize.define<VideoChannelInstance, VideoChannelAttributes>('VideoChannel', 32 VideoChannel = sequelize.define<VideoChannelInstance, VideoChannelAttributes>('VideoChannel',
@@ -94,12 +96,14 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
94 loadByUUID, 96 loadByUUID,
95 loadByHostAndUUID, 97 loadByHostAndUUID,
96 loadAndPopulateAccountAndVideos, 98 loadAndPopulateAccountAndVideos,
97 countByAccount 99 countByAccount,
100 loadByUrl,
101 loadByUUIDOrUrl
98 ] 102 ]
99 const instanceMethods = [ 103 const instanceMethods = [
100 isOwned, 104 isOwned,
101 toFormattedJSON, 105 toFormattedJSON,
102 toActivityPubObject, 106 toActivityPubObject
103 ] 107 ]
104 addMethodsToModel(VideoChannel, classMethods, instanceMethods) 108 addMethodsToModel(VideoChannel, classMethods, instanceMethods)
105 109
@@ -254,6 +258,33 @@ loadByUUID = function (uuid: string, t?: Sequelize.Transaction) {
254 return VideoChannel.findOne(query) 258 return VideoChannel.findOne(query)
255} 259}
256 260
261loadByUrl = function (url: string, t?: Sequelize.Transaction) {
262 const query: Sequelize.FindOptions<VideoChannelAttributes> = {
263 where: {
264 url
265 }
266 }
267
268 if (t !== undefined) query.transaction = t
269
270 return VideoChannel.findOne(query)
271}
272
273loadByUUIDOrUrl = function (uuid: string, url: string, t?: Sequelize.Transaction) {
274 const query: Sequelize.FindOptions<VideoChannelAttributes> = {
275 where: {
276 [Sequelize.Op.or]: [
277 { uuid },
278 { url }
279 ]
280 },
281 }
282
283 if (t !== undefined) query.transaction = t
284
285 return VideoChannel.findOne(query)
286}
287
257loadByHostAndUUID = function (fromHost: string, uuid: string, t?: Sequelize.Transaction) { 288loadByHostAndUUID = function (fromHost: string, uuid: string, t?: Sequelize.Transaction) {
258 const query: Sequelize.FindOptions<VideoChannelAttributes> = { 289 const query: Sequelize.FindOptions<VideoChannelAttributes> = {
259 where: { 290 where: {