import {
activityPubContextify,
isAccountFollowersCountValid,
- isAccountFollowersValid,
isAccountFollowingCountValid,
- isAccountFollowingValid,
- isAccountInboxValid,
- isAccountOutboxValid,
isAccountPrivateKeyValid,
isAccountPublicKeyValid,
- isAccountSharedInboxValid,
- isAccountUrlValid,
isUserUsernameValid
} from '../../helpers'
+import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants'
import { sendDeleteAccount } from '../../lib/activitypub/send/send-delete'
-
import { addMethodsToModel } from '../utils'
import { AccountAttributes, AccountInstance, AccountMethods } from './account-interface'
let loadByUrl: AccountMethods.LoadByUrl
let loadLocalByName: AccountMethods.LoadLocalByName
let loadByNameAndHost: AccountMethods.LoadByNameAndHost
+let listByFollowersUrls: AccountMethods.ListByFollowersUrls
let isOwned: AccountMethods.IsOwned
let toActivityPubObject: AccountMethods.ToActivityPubObject
let toFormattedJSON: AccountMethods.ToFormattedJSON
allowNull: false,
validate: {
urlValid: value => {
- const res = isAccountUrlValid(value)
+ const res = isActivityPubUrlValid(value)
if (res === false) throw new Error('URL is not valid.')
}
}
allowNull: false,
validate: {
inboxUrlValid: value => {
- const res = isAccountInboxValid(value)
+ const res = isActivityPubUrlValid(value)
if (res === false) throw new Error('Inbox URL is not valid.')
}
}
allowNull: false,
validate: {
outboxUrlValid: value => {
- const res = isAccountOutboxValid(value)
+ const res = isActivityPubUrlValid(value)
if (res === false) throw new Error('Outbox URL is not valid.')
}
}
allowNull: false,
validate: {
sharedInboxUrlValid: value => {
- const res = isAccountSharedInboxValid(value)
+ const res = isActivityPubUrlValid(value)
if (res === false) throw new Error('Shared inbox URL is not valid.')
}
}
allowNull: false,
validate: {
followersUrlValid: value => {
- const res = isAccountFollowersValid(value)
+ const res = isActivityPubUrlValid(value)
if (res === false) throw new Error('Followers URL is not valid.')
}
}
allowNull: false,
validate: {
followingUrlValid: value => {
- const res = isAccountFollowingValid(value)
+ const res = isActivityPubUrlValid(value)
if (res === false) throw new Error('Following URL is not valid.')
}
}
loadByUUID,
loadByUrl,
loadLocalByName,
- loadByNameAndHost
+ loadByNameAndHost,
+ listByFollowersUrls
]
const instanceMethods = [
isOwned,
return this.serverId === null
}
-getFollowerSharedInboxUrls = function (this: AccountInstance) {
+getFollowerSharedInboxUrls = function (this: AccountInstance, t: Sequelize.Transaction) {
const query: Sequelize.FindOptions<AccountAttributes> = {
attributes: [ 'sharedInboxUrl' ],
include: [
targetAccountId: this.id
}
}
- ]
+ ],
+ transaction: t
}
return Account.findAll(query)
return Account.findOne(query)
}
+
+listByFollowersUrls = function (followersUrls: string[], transaction?: Sequelize.Transaction) {
+ const query: Sequelize.FindOptions<AccountAttributes> = {
+ where: {
+ followersUrl: {
+ [Sequelize.Op.in]: followersUrls
+ }
+ },
+ transaction
+ }
+
+ return Account.findAll(query)
+}