From 25ed141c7c7631ef21d8764c1163fbf8a6591391 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 30 Nov 2017 11:31:15 +0100 Subject: Put activity pub sends inside transactions --- server/models/video/video-channel-share-interface.ts | 5 +++-- server/models/video/video-channel-share.ts | 10 ++++++---- server/models/video/video-share-interface.ts | 5 +++-- server/models/video/video-share.ts | 10 ++++++---- 4 files changed, 18 insertions(+), 12 deletions(-) (limited to 'server/models/video') diff --git a/server/models/video/video-channel-share-interface.ts b/server/models/video/video-channel-share-interface.ts index bcb3a0e24..0482e8297 100644 --- a/server/models/video/video-channel-share-interface.ts +++ b/server/models/video/video-channel-share-interface.ts @@ -1,11 +1,12 @@ import * as Bluebird from 'bluebird' import * as Sequelize from 'sequelize' +import { Transaction } from 'sequelize' import { AccountInstance } from '../account/account-interface' import { VideoChannelInstance } from './video-channel-interface' export namespace VideoChannelShareMethods { - export type LoadAccountsByShare = (videoChannelId: number) => Bluebird - export type Load = (accountId: number, videoId: number) => Bluebird + export type LoadAccountsByShare = (videoChannelId: number, t: Transaction) => Bluebird + export type Load = (accountId: number, videoId: number, t: Transaction) => Bluebird } export interface VideoChannelShareClass { diff --git a/server/models/video/video-channel-share.ts b/server/models/video/video-channel-share.ts index e47c0dae7..2e9b658a3 100644 --- a/server/models/video/video-channel-share.ts +++ b/server/models/video/video-channel-share.ts @@ -52,7 +52,7 @@ function associate (models) { }) } -load = function (accountId: number, videoChannelId: number) { +load = function (accountId: number, videoChannelId: number, t: Sequelize.Transaction) { return VideoChannelShare.findOne({ where: { accountId, @@ -61,11 +61,12 @@ load = function (accountId: number, videoChannelId: number) { include: [ VideoChannelShare['sequelize'].models.Account, VideoChannelShare['sequelize'].models.VideoChannel - ] + ], + transaction: t }) } -loadAccountsByShare = function (videoChannelId: number) { +loadAccountsByShare = function (videoChannelId: number, t: Sequelize.Transaction) { const query = { where: { videoChannelId @@ -75,7 +76,8 @@ loadAccountsByShare = function (videoChannelId: number) { model: VideoChannelShare['sequelize'].models.Account, required: true } - ] + ], + transaction: t } return VideoChannelShare.findAll(query) diff --git a/server/models/video/video-share-interface.ts b/server/models/video/video-share-interface.ts index ad23444b6..8ad10e095 100644 --- a/server/models/video/video-share-interface.ts +++ b/server/models/video/video-share-interface.ts @@ -1,11 +1,12 @@ import * as Bluebird from 'bluebird' import * as Sequelize from 'sequelize' +import { Transaction } from 'sequelize' import { AccountInstance } from '../account/account-interface' import { VideoInstance } from './video-interface' export namespace VideoShareMethods { - export type LoadAccountsByShare = (videoId: number) => Bluebird - export type Load = (accountId: number, videoId: number) => Bluebird + export type LoadAccountsByShare = (videoId: number, t: Transaction) => Bluebird + export type Load = (accountId: number, videoId: number, t: Transaction) => Bluebird } export interface VideoShareClass { diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index fe5d56d42..37e405fa9 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts @@ -52,7 +52,7 @@ function associate (models) { }) } -load = function (accountId: number, videoId: number) { +load = function (accountId: number, videoId: number, t: Sequelize.Transaction) { return VideoShare.findOne({ where: { accountId, @@ -60,11 +60,12 @@ load = function (accountId: number, videoId: number) { }, include: [ VideoShare['sequelize'].models.Account - ] + ], + transaction: t }) } -loadAccountsByShare = function (videoId: number) { +loadAccountsByShare = function (videoId: number, t: Sequelize.Transaction) { const query = { where: { videoId @@ -74,7 +75,8 @@ loadAccountsByShare = function (videoId: number) { model: VideoShare['sequelize'].models.Account, required: true } - ] + ], + transaction: t } return VideoShare.findAll(query) -- cgit v1.2.3