mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 01:47:39 -07:00
[backend] Catch errors in UserRepository.userFromURI
This fixes sporadic errors during rendering of follower/following lists.
This commit is contained in:
parent
d8a75cdd08
commit
1c6ec9ad08
1 changed files with 21 additions and 16 deletions
|
@ -241,24 +241,29 @@ export const UserRepository = db.getRepository(User).extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
async userFromURI(uri: string): Promise<User | null> {
|
async userFromURI(uri: string): Promise<User | null> {
|
||||||
const dbResolver = new DbResolver();
|
try {
|
||||||
let local = await dbResolver.getUserFromApId(uri);
|
const dbResolver = new DbResolver();
|
||||||
if (local) {
|
let local = await dbResolver.getUserFromApId(uri);
|
||||||
return local;
|
if (local) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isActor(object) ? await createPerson(getApId(object)) : null;
|
||||||
}
|
}
|
||||||
|
catch {
|
||||||
// fetching Object once from remote
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return isActor(object) ? await createPerson(getApId(object)) : null;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async getHasUnreadAntenna(userId: User["id"]): Promise<boolean> {
|
async getHasUnreadAntenna(userId: User["id"]): Promise<boolean> {
|
||||||
|
|
Loading…
Reference in a new issue