New API route format to make code cleaner

This commit is contained in:
Jesse Wierzbinski 2023-10-15 17:51:29 -10:00
parent c7b2f5b741
commit ca7d325cb1
36 changed files with 600 additions and 237 deletions

View file

@ -193,7 +193,7 @@ export class RawActivity extends BaseEntity {
* Returns the ActivityPub representation of the activity.
* @returns The ActivityPub representation of the activity.
*/
makeActivityPubRepresentation() {
getActivityPubRepresentation() {
return {
...this.data,
object: this.objects[0].data,

View file

@ -156,6 +156,13 @@ export class User extends BaseEntity {
@JoinTable()
pinned_notes!: RawObject[];
static async getFromRequest(req: Request) {
// Check auth token
const token = req.headers.get("Authorization")?.split(" ")[1] || "";
return { user: await User.retrieveFromToken(token), token };
}
/**
* Update this user data from its actor
* @returns The updated user.