mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
chore(federation): 👽 Initial Versia Working Draft 4.0 support
This commit is contained in:
parent
9c71c3fe51
commit
c3fa867e74
22 changed files with 269 additions and 197 deletions
|
|
@ -1,15 +1,16 @@
|
|||
import type { Undo } from "@lysand-org/federation/types";
|
||||
import { config } from "~/packages/config-manager/index";
|
||||
import type { Unfollow } from "@versia/federation/types";
|
||||
import type { User } from "~/packages/database-interface/user";
|
||||
|
||||
export const undoFederationRequest = (undoer: User, uri: string): Undo => {
|
||||
export const unfollowFederationRequest = (
|
||||
unfollower: User,
|
||||
unfollowing: User,
|
||||
): Unfollow => {
|
||||
const id = crypto.randomUUID();
|
||||
return {
|
||||
type: "Undo",
|
||||
type: "Unfollow",
|
||||
id,
|
||||
author: undoer.getUri(),
|
||||
author: unfollower.getUri(),
|
||||
created_at: new Date().toISOString(),
|
||||
object: uri,
|
||||
uri: new URL(`/undos/${id}`, config.http.base_url).toString(),
|
||||
followee: unfollowing.getUri(),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { Like } from "@lysand-org/federation/types";
|
||||
import type { LikeExtension } from "@versia/federation/types";
|
||||
import { type InferSelectModel, and, eq } from "drizzle-orm";
|
||||
import { db } from "~/drizzle/db";
|
||||
import { Likes, Notifications } from "~/drizzle/schema";
|
||||
|
|
@ -11,15 +11,15 @@ export type LikeType = InferSelectModel<typeof Likes>;
|
|||
/**
|
||||
* Represents a Like entity in the database.
|
||||
*/
|
||||
export const likeToVersia = (like: LikeType): Like => {
|
||||
export const likeToVersia = (like: LikeType): LikeExtension => {
|
||||
return {
|
||||
id: like.id,
|
||||
// biome-ignore lint/suspicious/noExplicitAny: to be rewritten
|
||||
author: (like as any).liker?.uri,
|
||||
type: "Like",
|
||||
type: "pub.versia:likes/Like",
|
||||
created_at: new Date(like.createdAt).toISOString(),
|
||||
// biome-ignore lint/suspicious/noExplicitAny: to be rewritten
|
||||
object: (like as any).liked?.uri,
|
||||
liked: (like as any).liked?.uri,
|
||||
uri: new URL(`/objects/${like.id}`, config.http.base_url).toString(),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { mentionValidator } from "@/api";
|
||||
import { sanitizeHtml, sanitizeHtmlInline } from "@/sanitization";
|
||||
import markdownItTaskLists from "@hackmd/markdown-it-task-lists";
|
||||
import type { ContentFormat } from "@lysand-org/federation/types";
|
||||
import type { ContentFormat } from "@versia/federation/types";
|
||||
import {
|
||||
type InferSelectModel,
|
||||
and,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import type {
|
|||
Follow,
|
||||
FollowAccept,
|
||||
FollowReject,
|
||||
} from "@lysand-org/federation/types";
|
||||
} from "@versia/federation/types";
|
||||
import { type InferSelectModel, eq, sql } from "drizzle-orm";
|
||||
import { db } from "~/drizzle/db";
|
||||
import {
|
||||
|
|
@ -12,7 +12,6 @@ import {
|
|||
Tokens,
|
||||
type Users,
|
||||
} from "~/drizzle/schema";
|
||||
import { config } from "~/packages/config-manager/index";
|
||||
import type { EmojiWithInstance } from "~/packages/database-interface/emoji";
|
||||
import { User } from "~/packages/database-interface/user";
|
||||
import type { Application } from "./application";
|
||||
|
|
@ -282,7 +281,6 @@ export const followRequestToVersia = (
|
|||
author: follower.getUri(),
|
||||
followee: followee.getUri(),
|
||||
created_at: new Date().toISOString(),
|
||||
uri: new URL(`/follows/${id}`, config.http.base_url).toString(),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -310,7 +308,6 @@ export const followAcceptToVersia = (
|
|||
author: followee.getUri(),
|
||||
created_at: new Date().toISOString(),
|
||||
follower: follower.getUri(),
|
||||
uri: new URL(`/follows/${id}`, config.http.base_url).toString(),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue