Loading .vscode/settings.json +2 −1 Original line number Diff line number Diff line { "yaml.schemas": { "https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json": ".gitlab/**/*.yml" } }, "prisma.pinToPrisma6": true } backend/prisma/schema.prisma +11 −0 Original line number Diff line number Diff line Loading @@ -60,3 +60,14 @@ model HandoffSession { updatedAt DateTime @default(now()) @updatedAt expiresAt DateTime } model SidecarSession { id String @id @default(uuid()) consumerClientId String sessionData String? userId String? // null when not yet authenticated createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt expiresAt DateTime } backend/src/apub/federation.ts +1 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,7 @@ federation if (object instanceof Note || object instanceof ChatMessage) { Handoff.get().activitypub.handle(actor, object, create); Handoff.get().sidecar.handle(actor, object); } else { console.log("create object unknown type", create, object); } Loading backend/src/apub/utils.live.ts +15 −4 Original line number Diff line number Diff line import { Actor, ChatMessage, ConstructorWithTypeId, Context, Create, Delete, Loading @@ -10,13 +11,15 @@ import { lookupWebFinger, Mention, Note, Object, Tombstone, } from "@fedify/fedify"; import { federation, USER_IDENTIFIER } from "./federation.js"; import { Temporal } from "@js-temporal/polyfill"; import { AuthSession } from "../models/AuthSession.js"; import { IProfile } from "../lib/instance/userMeta.js"; import { getSafeURL } from "../lib/utils.js"; import { _staticType, getSafeURL } from "../lib/utils.js"; import { IAPubUtils, IAPubUtils_Static } from "./utils.js"; type BuildObjectOpts = { id: string; Loading @@ -25,7 +28,7 @@ type BuildObjectOpts = { target: Actor; }; export class APubLive { export class APubLive implements IAPubUtils { ctx: Context<void>; constructor(ctx: Context<void>) { Loading Loading @@ -221,7 +224,7 @@ export class APubLive { ); } private async deleteChatMessage(id: string, target: Actor) { async deleteChatMessage(id: string, target: Actor) { const sender = this.ctx.getActorUri(USER_IDENTIFIER); await this.ctx.sendActivity( Loading Loading @@ -257,7 +260,7 @@ export class APubLive { ); } private async deleteNote(id: string, target: Actor) { async deleteNote(id: string, target: Actor) { const sender = this.ctx.getActorUri(USER_IDENTIFIER); await this.ctx.sendActivity( Loading @@ -274,6 +277,12 @@ export class APubLive { ); } getObjectUri = <TObject extends Object>( cls: ConstructorWithTypeId<TObject>, values: Record<string, string>, ) => this.ctx.getObjectUri(cls, values); getActorUri = (identifier: string) => this.ctx.getActorUri(identifier); build(type: "ChatMessage", opts: BuildObjectOpts): ChatMessage; build(type: "Note", opts: BuildObjectOpts): Note; build(type: "ChatMessage" | "Note", opts: BuildObjectOpts): unknown { Loading Loading @@ -314,3 +323,5 @@ Do not share this code. This code is used to identify you.`, } } } _staticType<IAPubUtils_Static>(APubLive); backend/src/apub/utils.stub.ts +15 −7 Original line number Diff line number Diff line Loading @@ -6,8 +6,10 @@ import { Actor, ChatMessage, ConstructorWithTypeId, Context, Note, Object, Person, ResourceDescriptor, } from "@fedify/fedify"; Loading @@ -15,12 +17,10 @@ import { IProfile } from "../lib/instance/userMeta.js"; import { USER_IDENTIFIER } from "./federation.js"; import { APubLive } from "./utils.live.js"; import { AuthSession } from "../models/AuthSession.js"; import { _staticType } from "../lib/utils.js"; import { IAPubUtils, IAPubUtils_Static } from "./utils.js"; export class APubStub extends APubLive { constructor() { super(null as any); } export class APubStub implements IAPubUtils { static options = () => ({}); static get accountHandle() { Loading Loading @@ -73,13 +73,21 @@ export class APubStub extends APubLive { async sendChatMessage(id: string, target: Actor, content: ChatMessage) {} async deleteChatMessage(id: string, target: Actor) {} async sendNote(id: string, target: Actor, content: Note) {} async deleteNote(id: string, target: Actor) {} getObjectUri = (cls: unknown, values: Record<string, unknown>) => new URL(`http://localhost/object/${String(cls)}-${JSON.stringify(values)}`); getActorUri = (identifier: string) => new URL(`/actor/${identifier}`, "http://localhost"); build( type: "ChatMessage" | "Note", opts: { id: string; one_time_code: string; createdAt: Date; target: Actor }, ): any {} } const _staticTypeCheck: typeof APubLive = APubStub; _staticTypeCheck.get(); // to ignore "unused variable" but still trigger type check _staticType<IAPubUtils_Static>(APubStub); Loading
.vscode/settings.json +2 −1 Original line number Diff line number Diff line { "yaml.schemas": { "https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json": ".gitlab/**/*.yml" } }, "prisma.pinToPrisma6": true }
backend/prisma/schema.prisma +11 −0 Original line number Diff line number Diff line Loading @@ -60,3 +60,14 @@ model HandoffSession { updatedAt DateTime @default(now()) @updatedAt expiresAt DateTime } model SidecarSession { id String @id @default(uuid()) consumerClientId String sessionData String? userId String? // null when not yet authenticated createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt expiresAt DateTime }
backend/src/apub/federation.ts +1 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,7 @@ federation if (object instanceof Note || object instanceof ChatMessage) { Handoff.get().activitypub.handle(actor, object, create); Handoff.get().sidecar.handle(actor, object); } else { console.log("create object unknown type", create, object); } Loading
backend/src/apub/utils.live.ts +15 −4 Original line number Diff line number Diff line import { Actor, ChatMessage, ConstructorWithTypeId, Context, Create, Delete, Loading @@ -10,13 +11,15 @@ import { lookupWebFinger, Mention, Note, Object, Tombstone, } from "@fedify/fedify"; import { federation, USER_IDENTIFIER } from "./federation.js"; import { Temporal } from "@js-temporal/polyfill"; import { AuthSession } from "../models/AuthSession.js"; import { IProfile } from "../lib/instance/userMeta.js"; import { getSafeURL } from "../lib/utils.js"; import { _staticType, getSafeURL } from "../lib/utils.js"; import { IAPubUtils, IAPubUtils_Static } from "./utils.js"; type BuildObjectOpts = { id: string; Loading @@ -25,7 +28,7 @@ type BuildObjectOpts = { target: Actor; }; export class APubLive { export class APubLive implements IAPubUtils { ctx: Context<void>; constructor(ctx: Context<void>) { Loading Loading @@ -221,7 +224,7 @@ export class APubLive { ); } private async deleteChatMessage(id: string, target: Actor) { async deleteChatMessage(id: string, target: Actor) { const sender = this.ctx.getActorUri(USER_IDENTIFIER); await this.ctx.sendActivity( Loading Loading @@ -257,7 +260,7 @@ export class APubLive { ); } private async deleteNote(id: string, target: Actor) { async deleteNote(id: string, target: Actor) { const sender = this.ctx.getActorUri(USER_IDENTIFIER); await this.ctx.sendActivity( Loading @@ -274,6 +277,12 @@ export class APubLive { ); } getObjectUri = <TObject extends Object>( cls: ConstructorWithTypeId<TObject>, values: Record<string, string>, ) => this.ctx.getObjectUri(cls, values); getActorUri = (identifier: string) => this.ctx.getActorUri(identifier); build(type: "ChatMessage", opts: BuildObjectOpts): ChatMessage; build(type: "Note", opts: BuildObjectOpts): Note; build(type: "ChatMessage" | "Note", opts: BuildObjectOpts): unknown { Loading Loading @@ -314,3 +323,5 @@ Do not share this code. This code is used to identify you.`, } } } _staticType<IAPubUtils_Static>(APubLive);
backend/src/apub/utils.stub.ts +15 −7 Original line number Diff line number Diff line Loading @@ -6,8 +6,10 @@ import { Actor, ChatMessage, ConstructorWithTypeId, Context, Note, Object, Person, ResourceDescriptor, } from "@fedify/fedify"; Loading @@ -15,12 +17,10 @@ import { IProfile } from "../lib/instance/userMeta.js"; import { USER_IDENTIFIER } from "./federation.js"; import { APubLive } from "./utils.live.js"; import { AuthSession } from "../models/AuthSession.js"; import { _staticType } from "../lib/utils.js"; import { IAPubUtils, IAPubUtils_Static } from "./utils.js"; export class APubStub extends APubLive { constructor() { super(null as any); } export class APubStub implements IAPubUtils { static options = () => ({}); static get accountHandle() { Loading Loading @@ -73,13 +73,21 @@ export class APubStub extends APubLive { async sendChatMessage(id: string, target: Actor, content: ChatMessage) {} async deleteChatMessage(id: string, target: Actor) {} async sendNote(id: string, target: Actor, content: Note) {} async deleteNote(id: string, target: Actor) {} getObjectUri = (cls: unknown, values: Record<string, unknown>) => new URL(`http://localhost/object/${String(cls)}-${JSON.stringify(values)}`); getActorUri = (identifier: string) => new URL(`/actor/${identifier}`, "http://localhost"); build( type: "ChatMessage" | "Note", opts: { id: string; one_time_code: string; createdAt: Date; target: Actor }, ): any {} } const _staticTypeCheck: typeof APubLive = APubStub; _staticTypeCheck.get(); // to ignore "unused variable" but still trigger type check _staticType<IAPubUtils_Static>(APubStub);