forked from shadowfacts/shadowfacts.net
Fix errors on actors missing public keys
This commit is contained in:
parent
889739c880
commit
77ee132983
|
@ -56,8 +56,8 @@ export interface ActorObject {
|
||||||
endpoints?: {
|
endpoints?: {
|
||||||
sharedInbox?: string;
|
sharedInbox?: string;
|
||||||
}
|
}
|
||||||
publicKey: {
|
publicKey?: {
|
||||||
publicKeyPem: string;
|
publicKeyPem?: string;
|
||||||
};
|
};
|
||||||
icon: string | object | (string | object)[];
|
icon: string | object | (string | object)[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,9 @@ async function cacheActor(actorObject: ActorObject) {
|
||||||
actor.displayName = actorObject.name;
|
actor.displayName = actorObject.name;
|
||||||
actor.inbox = actorObject.inbox;
|
actor.inbox = actorObject.inbox;
|
||||||
actor.iconURL = iconURL;
|
actor.iconURL = iconURL;
|
||||||
actor.publicKeyPem = actorObject.publicKey.publicKeyPem;
|
if (actorObject.publicKey && actorObject.publicKey.publicKeyPem) {
|
||||||
|
actor.publicKeyPem = actorObject.publicKey.publicKeyPem;
|
||||||
|
}
|
||||||
actor.isFollower = false;
|
actor.isFollower = false;
|
||||||
await getConnection().manager.save(actor);
|
await getConnection().manager.save(actor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ export = async (req: Request, res: Response, next: NextFunction) => {
|
||||||
console.log(`Could not retrieve actor ${req.body.actor} to validate HTTP signature for`, req.body);
|
console.log(`Could not retrieve actor ${req.body.actor} to validate HTTP signature for`, req.body);
|
||||||
res.status(401).end("Could not retrieve actor to validate HTTP signature");
|
res.status(401).end("Could not retrieve actor to validate HTTP signature");
|
||||||
}
|
}
|
||||||
} else if (!validate(req, actor.publicKey.publicKeyPem)) {
|
} else if (!actor.publicKey || !actor.publicKey.publicKeyPem || !validate(req, actor.publicKey.publicKeyPem)) {
|
||||||
console.log(`Could not validate HTTP signature for ${req.body.actor}`);
|
console.log(`Could not validate HTTP signature for ${req.body.actor}`);
|
||||||
res.status(401).end("Could not validate HTTP signature");
|
res.status(401).end("Could not validate HTTP signature");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -23,8 +23,8 @@ export default class Actor {
|
||||||
@Column()
|
@Column()
|
||||||
iconURL: string;
|
iconURL: string;
|
||||||
|
|
||||||
@Column()
|
@Column({ nullable: true })
|
||||||
publicKeyPem: string;
|
publicKeyPem: string | null;
|
||||||
|
|
||||||
@OneToMany(type => Note, note => note.actor)
|
@OneToMany(type => Note, note => note.actor)
|
||||||
notes: Note[];
|
notes: Note[];
|
||||||
|
|
Loading…
Reference in New Issue