mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-12-01 14:27:33 -07:00
fixed it for good
This commit is contained in:
parent
09555da38f
commit
abe351c283
1 changed files with 20 additions and 13 deletions
|
@ -12,7 +12,10 @@ import { getAntennas } from '@/misc/antenna-cache.js';
|
||||||
import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const.js';
|
import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const.js';
|
||||||
import { Cache } from '@/misc/cache.js';
|
import { Cache } from '@/misc/cache.js';
|
||||||
import { db } from '@/db/postgre.js';
|
import { db } from '@/db/postgre.js';
|
||||||
import { resolveUser } from '@/remote/resolve-user.js';
|
import { isActor, getApId } from '@/remote/activitypub/type.js';
|
||||||
|
import DbResolver from '@/remote/activitypub/db-resolver.js';
|
||||||
|
import Resolver from '@/remote/activitypub/resolver.js';
|
||||||
|
import { createPerson } from '@/remote/activitypub/models/person.js';
|
||||||
import {
|
import {
|
||||||
AnnouncementReads,
|
AnnouncementReads,
|
||||||
Announcements,
|
Announcements,
|
||||||
|
@ -181,20 +184,24 @@ export const UserRepository = db.getRepository(User).extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
async userFromURI(uri: string): Promise<User | null> {
|
async userFromURI(uri: string): Promise<User | null> {
|
||||||
if (uri.startsWith(config.url + '/')) {
|
const dbResolver = new DbResolver();
|
||||||
const id = uri.split('/').pop();
|
let local = await dbResolver.getUserFromApId(uri);
|
||||||
if (id == undefined) return null;
|
if (local) {
|
||||||
return await resolveUser(id, null);
|
return local;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetching Object once from remote
|
||||||
|
const resolver = new Resolver();
|
||||||
|
const object = await resolver.resolve(uri) as any;
|
||||||
|
|
||||||
|
// /@user If a URI other than the id is specified,
|
||||||
|
// the URI is determined here
|
||||||
|
if (uri !== object.id) {
|
||||||
|
local = await dbResolver.getUserFromApId(object.id);
|
||||||
|
if (local != null) return local;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = new URL(uri);
|
return isActor(object) ? await createPerson(getApId(object)) : null;
|
||||||
let userTag = url.pathname;
|
|
||||||
|
|
||||||
if (userTag.startsWith('@')) {
|
|
||||||
userTag = userTag.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await resolveUser(userTag, url.host);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async getHasUnreadAntenna(userId: User['id']): Promise<boolean> {
|
async getHasUnreadAntenna(userId: User['id']): Promise<boolean> {
|
||||||
|
|
Loading…
Reference in a new issue