Compare commits

...

1 Commits

Author SHA1 Message Date
Shadowfacts 77ee132983
Fix errors on actors missing public keys 2020-04-15 13:13:52 -04:00
4 changed files with 8 additions and 6 deletions

View File

@ -56,8 +56,8 @@ export interface ActorObject {
endpoints?: {
sharedInbox?: string;
}
publicKey: {
publicKeyPem: string;
publicKey?: {
publicKeyPem?: string;
};
icon: string | object | (string | object)[];
}

View File

@ -67,7 +67,9 @@ async function cacheActor(actorObject: ActorObject) {
actor.displayName = actorObject.name;
actor.inbox = actorObject.inbox;
actor.iconURL = iconURL;
if (actorObject.publicKey && actorObject.publicKey.publicKeyPem) {
actor.publicKeyPem = actorObject.publicKey.publicKeyPem;
}
actor.isFollower = false;
await getConnection().manager.save(actor);
}

View File

@ -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);
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}`);
res.status(401).end("Could not validate HTTP signature");
} else {

View File

@ -23,8 +23,8 @@ export default class Actor {
@Column()
iconURL: string;
@Column()
publicKeyPem: string;
@Column({ nullable: true })
publicKeyPem: string | null;
@OneToMany(type => Note, note => note.actor)
notes: Note[];