Fix federated interactions and reply threads

This commit is contained in:
cyph3rasi
2026-03-07 21:27:22 -08:00
parent 1e2da4f2da
commit 5d524a0354
21 changed files with 241 additions and 59 deletions
@@ -14,15 +14,16 @@ import { db, users, notifications, remoteFollowers } from '@/db';
import { eq, and, sql } from 'drizzle-orm';
import { z } from 'zod';
import { verifyUserInteraction } from '@/lib/swarm/signature';
import { localHandleSchema, nodeDomainSchema } from '@/lib/utils/federation';
const swarmFollowSchema = z.object({
targetHandle: z.string().min(3).max(30).regex(/^[a-zA-Z0-9_]+$/, 'Handle must be alphanumeric with underscores'),
targetHandle: localHandleSchema,
follow: z.object({
followerHandle: z.string().min(3).max(30).regex(/^[a-zA-Z0-9_]+$/, 'Handle must be alphanumeric with underscores'),
followerHandle: localHandleSchema,
followerDisplayName: z.string().min(1).max(50),
followerAvatarUrl: z.string().url().optional(),
followerBio: z.string().max(500).optional(),
followerNodeDomain: z.string().min(1).regex(/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/, 'Invalid domain format'),
followerNodeDomain: nodeDomainSchema,
interactionId: z.string().uuid(),
timestamp: z.string().datetime(),
}),
+3 -2
View File
@@ -11,14 +11,15 @@ import { db, posts, users, notifications, remoteLikes } from '@/db';
import { eq, and } from 'drizzle-orm';
import { z } from 'zod';
import { verifyUserInteraction } from '@/lib/swarm/signature';
import { localHandleSchema, nodeDomainSchema } from '@/lib/utils/federation';
const swarmLikeSchema = z.object({
postId: z.string().uuid(),
like: z.object({
actorHandle: z.string().min(3).max(30).regex(/^[a-zA-Z0-9_]+$/, 'Handle must be alphanumeric with underscores'),
actorHandle: localHandleSchema,
actorDisplayName: z.string().min(1).max(50),
actorAvatarUrl: z.string().url().optional(),
actorNodeDomain: z.string().min(1).regex(/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/, 'Invalid domain format'),
actorNodeDomain: nodeDomainSchema,
interactionId: z.string().uuid(),
timestamp: z.string().datetime(),
}),
@@ -11,18 +11,19 @@ import { db, users, notifications } from '@/db';
import { eq } from 'drizzle-orm';
import { z } from 'zod';
import { verifyUserInteraction } from '@/lib/swarm/signature';
import { localHandleSchema, nodeDomainSchema } from '@/lib/utils/federation';
const swarmMentionSchema = z.object({
mentionedHandle: z.string(),
mentionedHandle: localHandleSchema,
mention: z.object({
actorHandle: z.string(),
actorDisplayName: z.string(),
actorAvatarUrl: z.string().optional(),
actorNodeDomain: z.string(),
postId: z.string(),
postContent: z.string(),
interactionId: z.string(),
timestamp: z.string(),
actorHandle: localHandleSchema,
actorDisplayName: z.string().min(1).max(50),
actorAvatarUrl: z.string().url().optional(),
actorNodeDomain: nodeDomainSchema,
postId: z.string().uuid(),
postContent: z.string().max(10000),
interactionId: z.string().uuid(),
timestamp: z.string().datetime(),
}),
signature: z.string(),
});
@@ -11,14 +11,15 @@ import { db, posts, users, notifications } from '@/db';
import { eq, sql } from 'drizzle-orm';
import { z } from 'zod';
import { verifyUserInteraction } from '@/lib/swarm/signature';
import { localHandleSchema, nodeDomainSchema } from '@/lib/utils/federation';
const swarmRepostSchema = z.object({
postId: z.string().uuid(),
repost: z.object({
actorHandle: z.string().min(3).max(30).regex(/^[a-zA-Z0-9_]+$/, 'Handle must be alphanumeric with underscores'),
actorHandle: localHandleSchema,
actorDisplayName: z.string().min(1).max(50),
actorAvatarUrl: z.string().url().optional(),
actorNodeDomain: z.string().min(1).regex(/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/, 'Invalid domain format'),
actorNodeDomain: nodeDomainSchema,
repostId: z.string().uuid(),
interactionId: z.string().uuid(),
timestamp: z.string().datetime(),
@@ -11,14 +11,15 @@ import { db, users, remoteFollowers } from '@/db';
import { eq, and, sql } from 'drizzle-orm';
import { z } from 'zod';
import { verifyUserInteraction } from '@/lib/swarm/signature';
import { localHandleSchema, nodeDomainSchema } from '@/lib/utils/federation';
const swarmUnfollowSchema = z.object({
targetHandle: z.string(),
targetHandle: localHandleSchema,
unfollow: z.object({
followerHandle: z.string(),
followerNodeDomain: z.string(),
interactionId: z.string(),
timestamp: z.string(),
followerHandle: localHandleSchema,
followerNodeDomain: nodeDomainSchema,
interactionId: z.string().uuid(),
timestamp: z.string().datetime(),
}),
signature: z.string(),
});
@@ -11,14 +11,15 @@ import { db, posts, remoteLikes } from '@/db';
import { eq, and } from 'drizzle-orm';
import { z } from 'zod';
import { verifyUserInteraction } from '@/lib/swarm/signature';
import { localHandleSchema, nodeDomainSchema } from '@/lib/utils/federation';
const swarmUnlikeSchema = z.object({
postId: z.string().uuid(),
unlike: z.object({
actorHandle: z.string(),
actorNodeDomain: z.string(),
interactionId: z.string(),
timestamp: z.string(),
actorHandle: localHandleSchema,
actorNodeDomain: nodeDomainSchema,
interactionId: z.string().uuid(),
timestamp: z.string().datetime(),
}),
signature: z.string(),
});
@@ -11,14 +11,15 @@ import { db, posts } from '@/db';
import { eq, sql } from 'drizzle-orm';
import { z } from 'zod';
import { verifyUserInteraction } from '@/lib/swarm/signature';
import { localHandleSchema, nodeDomainSchema } from '@/lib/utils/federation';
const swarmUnrepostSchema = z.object({
postId: z.string().uuid(),
unrepost: z.object({
actorHandle: z.string(),
actorNodeDomain: z.string(),
interactionId: z.string(),
timestamp: z.string(),
actorHandle: localHandleSchema,
actorNodeDomain: nodeDomainSchema,
interactionId: z.string().uuid(),
timestamp: z.string().datetime(),
}),
signature: z.string(),
});