From d846501818c2d29e66e6fd141789cb04fd55a437 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Nov 2017 17:56:21 +0100 Subject: Handle announces in inbox --- server/models/video/index.ts | 2 + .../models/video/video-channel-share-interface.ts | 27 ++++++++++++ server/models/video/video-channel-share.ts | 49 ++++++++++++++++++++++ server/models/video/video-share-interface.ts | 25 +++++++++++ server/models/video/video-share.ts | 49 ++++++++++++++++++++++ server/models/video/video.ts | 11 ----- 6 files changed, 152 insertions(+), 11 deletions(-) create mode 100644 server/models/video/video-channel-share-interface.ts create mode 100644 server/models/video/video-channel-share.ts create mode 100644 server/models/video/video-share-interface.ts create mode 100644 server/models/video/video-share.ts (limited to 'server/models/video') diff --git a/server/models/video/index.ts b/server/models/video/index.ts index 20d97931f..e17bbfab4 100644 --- a/server/models/video/index.ts +++ b/server/models/video/index.ts @@ -5,3 +5,5 @@ export * from './video-channel-interface' export * from './video-tag-interface' export * from './video-file-interface' export * from './video-interface' +export * from './video-share-interface' +export * from './video-channel-share-interface' diff --git a/server/models/video/video-channel-share-interface.ts b/server/models/video/video-channel-share-interface.ts new file mode 100644 index 000000000..9ac6d7b23 --- /dev/null +++ b/server/models/video/video-channel-share-interface.ts @@ -0,0 +1,27 @@ +import * as Sequelize from 'sequelize' +import { AccountInstance } from '../account/account-interface' +import { VideoChannelInstance } from './video-channel-interface' + +export namespace VideoChannelShareMethods { +} + +export interface VideoChannelShareClass { +} + +export interface VideoChannelShareAttributes { + accountId: number + videoChannelId: number +} + +export interface VideoChannelShareInstance + extends VideoChannelShareClass, VideoChannelShareAttributes, Sequelize.Instance { + id: number + createdAt: Date + updatedAt: Date + + Account?: AccountInstance + VideoChannel?: VideoChannelInstance +} + +export interface VideoChannelShareModel + extends VideoChannelShareClass, Sequelize.Model {} diff --git a/server/models/video/video-channel-share.ts b/server/models/video/video-channel-share.ts new file mode 100644 index 000000000..b6199279f --- /dev/null +++ b/server/models/video/video-channel-share.ts @@ -0,0 +1,49 @@ +import * as Sequelize from 'sequelize' + +import { addMethodsToModel } from '../utils' +import { VideoChannelShareAttributes, VideoChannelShareInstance } from './video-channel-share-interface' + +let VideoChannelShare: Sequelize.Model + +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + VideoChannelShare = sequelize.define('VideoChannelShare', + { }, + { + indexes: [ + { + fields: [ 'accountId' ] + }, + { + fields: [ 'videoChannelId' ] + } + ] + } + ) + + const classMethods = [ + associate + ] + addMethodsToModel(VideoChannelShare, classMethods) + + return VideoChannelShare +} + +// ------------------------------ METHODS ------------------------------ + +function associate (models) { + VideoChannelShare.belongsTo(models.Account, { + foreignKey: { + name: 'accountId', + allowNull: false + }, + onDelete: 'cascade' + }) + + VideoChannelShare.belongsTo(models.VideoChannel, { + foreignKey: { + name: 'videoChannelId', + allowNull: true + }, + onDelete: 'cascade' + }) +} diff --git a/server/models/video/video-share-interface.ts b/server/models/video/video-share-interface.ts new file mode 100644 index 000000000..7928b9a9c --- /dev/null +++ b/server/models/video/video-share-interface.ts @@ -0,0 +1,25 @@ +import * as Sequelize from 'sequelize' +import { AccountInstance } from '../account/account-interface' +import { VideoInstance } from './video-interface' + +export namespace VideoShareMethods { +} + +export interface VideoShareClass { +} + +export interface VideoShareAttributes { + accountId: number + videoId: number +} + +export interface VideoShareInstance extends VideoShareClass, VideoShareAttributes, Sequelize.Instance { + id: number + createdAt: Date + updatedAt: Date + + Account?: AccountInstance + Video?: VideoInstance +} + +export interface VideoShareModel extends VideoShareClass, Sequelize.Model {} diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts new file mode 100644 index 000000000..358491fd2 --- /dev/null +++ b/server/models/video/video-share.ts @@ -0,0 +1,49 @@ +import * as Sequelize from 'sequelize' + +import { addMethodsToModel } from '../utils' +import { VideoShareAttributes, VideoShareInstance } from './video-share-interface' + +let VideoShare: Sequelize.Model + +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + VideoShare = sequelize.define('VideoShare', + { }, + { + indexes: [ + { + fields: [ 'accountId' ] + }, + { + fields: [ 'videoId' ] + } + ] + } + ) + + const classMethods = [ + associate + ] + addMethodsToModel(VideoShare, classMethods) + + return VideoShare +} + +// ------------------------------ METHODS ------------------------------ + +function associate (models) { + VideoShare.belongsTo(models.Account, { + foreignKey: { + name: 'accountId', + allowNull: false + }, + onDelete: 'cascade' + }) + + VideoShare.belongsTo(models.Video, { + foreignKey: { + name: 'videoId', + allowNull: true + }, + onDelete: 'cascade' + }) +} diff --git a/server/models/video/video.ts b/server/models/video/video.ts index b00081f25..480e54276 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -253,9 +253,6 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da }, { fields: [ 'channelId' ] - }, - { - fields: [ 'parentId' ] } ], hooks: { @@ -329,14 +326,6 @@ function associate (models) { onDelete: 'cascade' }) - Video.belongsTo(models.Video, { - foreignKey: { - name: 'parentId', - allowNull: true - }, - onDelete: 'cascade' - }) - Video.belongsToMany(models.Tag, { foreignKey: 'videoId', through: models.VideoTag, -- cgit v1.2.3