From e8cb44090e654fda339506dccfcec7fea8722723 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 21 Feb 2018 16:44:18 +0100 Subject: Add links to comment mentions --- server/models/account/account.ts | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'server/models') diff --git a/server/models/account/account.ts b/server/models/account/account.ts index bc7595a0e..c5955ef3b 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -157,7 +157,6 @@ export class AccountModel extends Model { static loadLocalByName (name: string) { const query = { where: { - name, [ Sequelize.Op.or ]: [ { userId: { @@ -170,7 +169,41 @@ export class AccountModel extends Model { } } ] - } + }, + include: [ + { + model: ActorModel, + required: true, + where: { + preferredUsername: name + } + } + ] + } + + return AccountModel.findOne(query) + } + + static loadLocalByNameAndHost (name: string, host: string) { + const query = { + include: [ + { + model: ActorModel, + required: true, + where: { + preferredUsername: name + }, + include: [ + { + model: ServerModel, + required: true, + where: { + host + } + } + ] + } + ] } return AccountModel.findOne(query) -- cgit v1.2.3