MActorServer,
MActorSummaryFormattable, MActorUrl,
MActorWithInboxes
-} from '../../typings/models'
+} from '../../types/models'
import * as Bluebird from 'bluebird'
import { Op, Transaction, literal } from 'sequelize'
import { ModelCache } from '@server/models/model-cache'
'sharedInboxUrl',
'followersUrl',
'followingUrl',
- 'url',
'createdAt',
'updatedAt'
]
}
}
},
- // {
- // fields: [ 'preferredUsername' ],
- // unique: true,
- // where: {
- // serverId: null
- // }
- // },
+ {
+ fields: [ 'preferredUsername' ],
+ unique: true,
+ where: {
+ serverId: null
+ }
+ },
{
fields: [ 'inboxUrl', 'sharedInboxUrl' ]
},
}, { where, transaction })
}
+ static loadAccountActorByVideoId (videoId: number): Bluebird<MActor> {
+ const query = {
+ include: [
+ {
+ attributes: [ 'id' ],
+ model: AccountModel.unscoped(),
+ required: true,
+ include: [
+ {
+ attributes: [ 'id', 'accountId' ],
+ model: VideoChannelModel.unscoped(),
+ required: true,
+ include: [
+ {
+ attributes: [ 'id', 'channelId' ],
+ model: VideoModel.unscoped(),
+ where: {
+ id: videoId
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+
+ return ActorModel.unscoped().findOne(query)
+ }
+
getSharedInbox (this: MActorWithInboxes) {
return this.sharedInboxUrl || this.inboxUrl
}