diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-25 15:55:31 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-25 15:55:31 +0100 |
commit | a77c7327a25b95b314dfcdb25f239f0e4a85096c (patch) | |
tree | 9cd21d758537280fe4473bc331d0f9f156a32365 | |
parent | e7812bf0919ebc8e41d53ff981e1fbf77282e86f (diff) | |
download | PeerTube-a77c7327a25b95b314dfcdb25f239f0e4a85096c.tar.gz PeerTube-a77c7327a25b95b314dfcdb25f239f0e4a85096c.tar.zst PeerTube-a77c7327a25b95b314dfcdb25f239f0e4a85096c.zip |
Fix process abuse transactions
-rw-r--r-- | server/lib/activitypub/process/process-flag.ts | 7 | ||||
-rw-r--r-- | server/lib/oauth-model.ts | 20 |
2 files changed, 13 insertions, 14 deletions
diff --git a/server/lib/activitypub/process/process-flag.ts b/server/lib/activitypub/process/process-flag.ts index 40d07558c..7ed409d0e 100644 --- a/server/lib/activitypub/process/process-flag.ts +++ b/server/lib/activitypub/process/process-flag.ts | |||
@@ -49,13 +49,12 @@ async function processCreateAbuse (activity: ActivityCreate | ActivityFlag, byAc | |||
49 | logger.debug('Reporting remote abuse for object %s.', uri) | 49 | logger.debug('Reporting remote abuse for object %s.', uri) |
50 | 50 | ||
51 | await sequelizeTypescript.transaction(async t => { | 51 | await sequelizeTypescript.transaction(async t => { |
52 | 52 | const video = await VideoModel.loadByUrlAndPopulateAccount(uri, t) | |
53 | const video = await VideoModel.loadByUrlAndPopulateAccount(uri) | ||
54 | let videoComment: MCommentOwnerVideo | 53 | let videoComment: MCommentOwnerVideo |
55 | let flaggedAccount: MAccountDefault | 54 | let flaggedAccount: MAccountDefault |
56 | 55 | ||
57 | if (!video) videoComment = await VideoCommentModel.loadByUrlAndPopulateAccountAndVideo(uri) | 56 | if (!video) videoComment = await VideoCommentModel.loadByUrlAndPopulateAccountAndVideo(uri, t) |
58 | if (!videoComment) flaggedAccount = await AccountModel.loadByUrl(uri) | 57 | if (!videoComment) flaggedAccount = await AccountModel.loadByUrl(uri, t) |
59 | 58 | ||
60 | if (!video && !videoComment && !flaggedAccount) { | 59 | if (!video && !videoComment && !flaggedAccount) { |
61 | logger.warn('Cannot flag unknown entity %s.', object) | 60 | logger.warn('Cannot flag unknown entity %s.', object) |
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts index 75aee2567..a2c53a2c9 100644 --- a/server/lib/oauth-model.ts +++ b/server/lib/oauth-model.ts | |||
@@ -1,20 +1,20 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as LRUCache from 'lru-cache' | ||
2 | import { AccessDeniedError } from 'oauth2-server' | 3 | import { AccessDeniedError } from 'oauth2-server' |
3 | import { logger } from '../helpers/logger' | ||
4 | import { UserModel } from '../models/account/user' | ||
5 | import { OAuthClientModel } from '../models/oauth/oauth-client' | ||
6 | import { OAuthTokenModel } from '../models/oauth/oauth-token' | ||
7 | import { LRU_CACHE, OAUTH_LIFETIME } from '../initializers/constants' | ||
8 | import { Transaction } from 'sequelize' | 4 | import { Transaction } from 'sequelize' |
9 | import { CONFIG } from '../initializers/config' | 5 | import { PluginManager } from '@server/lib/plugins/plugin-manager' |
10 | import * as LRUCache from 'lru-cache' | 6 | import { ActorModel } from '@server/models/activitypub/actor' |
11 | import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' | 7 | import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' |
12 | import { MUser } from '@server/types/models/user/user' | 8 | import { MUser } from '@server/types/models/user/user' |
13 | import { UserAdminFlag } from '@shared/models/users/user-flag.model' | 9 | import { UserAdminFlag } from '@shared/models/users/user-flag.model' |
14 | import { createUserAccountAndChannelAndPlaylist } from './user' | ||
15 | import { UserRole } from '@shared/models/users/user-role' | 10 | import { UserRole } from '@shared/models/users/user-role' |
16 | import { PluginManager } from '@server/lib/plugins/plugin-manager' | 11 | import { logger } from '../helpers/logger' |
17 | import { ActorModel } from '@server/models/activitypub/actor' | 12 | import { CONFIG } from '../initializers/config' |
13 | import { LRU_CACHE } from '../initializers/constants' | ||
14 | import { UserModel } from '../models/account/user' | ||
15 | import { OAuthClientModel } from '../models/oauth/oauth-client' | ||
16 | import { OAuthTokenModel } from '../models/oauth/oauth-token' | ||
17 | import { createUserAccountAndChannelAndPlaylist } from './user' | ||
18 | 18 | ||
19 | type TokenInfo = { accessToken: string, refreshToken: string, accessTokenExpiresAt: Date, refreshTokenExpiresAt: Date } | 19 | type TokenInfo = { accessToken: string, refreshToken: string, accessTokenExpiresAt: Date, refreshTokenExpiresAt: Date } |
20 | 20 | ||