refactor(federation): ♻️ Remove Response return semantics from inbox worker

This commit is contained in:
Jesse Wierzbinski 2024-11-25 23:11:17 +01:00
parent 025d5bea94
commit a037448ebb
No known key found for this signature in database
4 changed files with 133 additions and 130 deletions

View file

@ -391,6 +391,32 @@ export class Instance extends BaseInterface<typeof Instances> {
return this;
}
public async sendMessage(content: string): Promise<void> {
const logger = getLogger(["federation", "messaging"]);
if (
!this.data.extensions?.["pub.versia:instance_messaging"]?.endpoint
) {
logger.info`Instance ${chalk.gray(
this.data.baseUrl,
)} does not support Instance Messaging, skipping message`;
return;
}
const endpoint = new URL(
this.data.extensions["pub.versia:instance_messaging"].endpoint,
);
await fetch(endpoint.href, {
method: "POST",
headers: {
"Content-Type": "text/plain",
},
body: content,
});
}
public static getCount(): Promise<number> {
return db.$count(Instances);
}