import { values } from 'lodash'
import { extname } from 'path'
-import * as Sequelize from 'sequelize'
import {
AllowNull,
BelongsTo,
MActorFull,
MActorHost,
MActorServer,
- MActorSummaryFormattable
+ MActorSummaryFormattable,
+ MActorWithInboxes
} from '../../typings/models'
import * as Bluebird from 'bluebird'
+import { Op, Transaction } from 'sequelize'
enum ScopeNames {
FULL = 'FULL'
},
{
fields: [ 'preferredUsername', 'serverId' ],
- unique: true
+ unique: true,
+ where: {
+ serverId: {
+ [Op.ne]: null
+ }
+ }
},
+ // {
+ // fields: [ 'preferredUsername' ],
+ // unique: true,
+ // where: {
+ // serverId: null
+ // }
+ // },
{
fields: [ 'inboxUrl', 'sharedInboxUrl' ]
},
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
outboxUrl: string
- @AllowNull(false)
- @Is('ActorSharedInboxUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'shared inbox url'))
+ @AllowNull(true)
+ @Is('ActorSharedInboxUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'shared inbox url', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
sharedInboxUrl: string
return ActorModel.scope(ScopeNames.FULL).findByPk(id)
}
- static loadFromAccountByVideoId (videoId: number, transaction: Sequelize.Transaction): Bluebird<MActor> {
+ static loadFromAccountByVideoId (videoId: number, transaction: Transaction): Bluebird<MActor> {
const query = {
include: [
{
.then(a => !!a)
}
- static listByFollowersUrls (followersUrls: string[], transaction?: Sequelize.Transaction): Bluebird<MActorFull[]> {
+ static listByFollowersUrls (followersUrls: string[], transaction?: Transaction): Bluebird<MActorFull[]> {
const query = {
where: {
followersUrl: {
- [ Sequelize.Op.in ]: followersUrls
+ [ Op.in ]: followersUrls
}
},
transaction
return ActorModel.scope(ScopeNames.FULL).findAll(query)
}
- static loadLocalByName (preferredUsername: string, transaction?: Sequelize.Transaction): Bluebird<MActorFull> {
+ static loadLocalByName (preferredUsername: string, transaction?: Transaction): Bluebird<MActorFull> {
const query = {
where: {
preferredUsername,
return ActorModel.scope(ScopeNames.FULL).findOne(query)
}
- static loadByUrl (url: string, transaction?: Sequelize.Transaction): Bluebird<MActorAccountChannelId> {
+ static loadByUrl (url: string, transaction?: Transaction): Bluebird<MActorAccountChannelId> {
const query = {
where: {
url
return ActorModel.unscoped().findOne(query)
}
- static loadByUrlAndPopulateAccountAndChannel (url: string, transaction?: Sequelize.Transaction): Bluebird<MActorFull> {
+ static loadByUrlAndPopulateAccountAndChannel (url: string, transaction?: Transaction): Bluebird<MActorFull> {
const query = {
where: {
url
})
}
+ getSharedInbox (this: MActorWithInboxes) {
+ return this.sharedInboxUrl || this.inboxUrl
+ }
+
toFormattedSummaryJSON (this: MActorSummaryFormattable) {
let avatar: Avatar = null
if (this.Avatar) {
}
toActivityPubObject (this: MActorAP, name: string) {
- let activityPubType
-
let icon = undefined
if (this.avatarId) {
const extension = extname(this.Avatar.filename)
return activityPubContextify(json)
}
- getFollowerSharedInboxUrls (t: Sequelize.Transaction) {
+ getFollowerSharedInboxUrls (t: Transaction) {
const query = {
attributes: [ 'sharedInboxUrl' ],
include: [