mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Don't notify on muted instance
This commit is contained in:
parent
96f6278f3e
commit
dddc8b1fe0
4 changed files with 262 additions and 19 deletions
|
@ -75,11 +75,6 @@ export class AccountBlocklistModel extends Model<AccountBlocklistModel> {
|
|||
})
|
||||
BlockedAccount: AccountModel
|
||||
|
||||
static isAccountMutedBy (accountId: number, targetAccountId: number) {
|
||||
return AccountBlocklistModel.isAccountMutedByMulti([ accountId ], targetAccountId)
|
||||
.then(result => result[accountId])
|
||||
}
|
||||
|
||||
static isAccountMutedByMulti (accountIds: number[], targetAccountId: number) {
|
||||
const query = {
|
||||
attributes: [ 'accountId', 'id' ],
|
||||
|
|
|
@ -5,6 +5,7 @@ import { ServerBlock } from '../../../shared/models/blocklist'
|
|||
import { getSort } from '../utils'
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { MServerBlocklist, MServerBlocklistAccountServer, MServerBlocklistFormattable } from '@server/typings/models'
|
||||
import { Op } from 'sequelize'
|
||||
|
||||
enum ScopeNames {
|
||||
WITH_ACCOUNT = 'WITH_ACCOUNT',
|
||||
|
@ -75,6 +76,31 @@ export class ServerBlocklistModel extends Model<ServerBlocklistModel> {
|
|||
})
|
||||
BlockedServer: ServerModel
|
||||
|
||||
static isServerMutedByMulti (accountIds: number[], targetServerId: number) {
|
||||
const query = {
|
||||
attributes: [ 'accountId', 'id' ],
|
||||
where: {
|
||||
accountId: {
|
||||
[Op.in]: accountIds // FIXME: sequelize ANY seems broken
|
||||
},
|
||||
targetServerId
|
||||
},
|
||||
raw: true
|
||||
}
|
||||
|
||||
return ServerBlocklistModel.unscoped()
|
||||
.findAll(query)
|
||||
.then(rows => {
|
||||
const result: { [accountId: number]: boolean } = {}
|
||||
|
||||
for (const accountId of accountIds) {
|
||||
result[accountId] = !!rows.find(r => r.accountId === accountId)
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
static loadByAccountAndHost (accountId: number, host: string): Bluebird<MServerBlocklist> {
|
||||
const query = {
|
||||
where: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue