Fix federated interactions and reply threads
This commit is contained in:
@@ -5,6 +5,7 @@ import { eq, and, sql } from 'drizzle-orm';
|
||||
import { requireAuth } from '@/lib/auth';
|
||||
import { requireSignedAction } from '@/lib/auth/verify-signature';
|
||||
import { isSwarmNode, deliverSwarmFollow, deliverSwarmUnfollow, cacheSwarmUserPosts } from '@/lib/swarm/interactions';
|
||||
import { discoverNode } from '@/lib/swarm/discovery';
|
||||
|
||||
type RouteContext = { params: Promise<{ handle: string }> };
|
||||
|
||||
@@ -115,7 +116,12 @@ export async function POST(request: Request, context: RouteContext) {
|
||||
}
|
||||
|
||||
// Only allow following swarm nodes
|
||||
const isSwarm = await isSwarmNode(remote.domain);
|
||||
let isSwarm = await isSwarmNode(remote.domain);
|
||||
if (!isSwarm) {
|
||||
const discovery = await discoverNode(remote.domain, nodeDomain);
|
||||
isSwarm = discovery.success;
|
||||
}
|
||||
|
||||
if (!isSwarm) {
|
||||
return NextResponse.json({ error: 'Can only follow users on Synapsis swarm nodes' }, { status: 400 });
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { NextResponse } from 'next/server';
|
||||
import { db, posts, users, likes } from '@/db';
|
||||
import { eq, desc, and, inArray, lt } from 'drizzle-orm';
|
||||
import { fetchSwarmUserProfile, isSwarmNode } from '@/lib/swarm/interactions';
|
||||
import { discoverNode } from '@/lib/swarm/discovery';
|
||||
|
||||
type RouteContext = { params: Promise<{ handle: string }> };
|
||||
|
||||
@@ -30,7 +31,12 @@ export async function GET(request: Request, context: RouteContext) {
|
||||
}
|
||||
|
||||
// Only fetch from swarm nodes
|
||||
const isSwarm = await isSwarmNode(remote.domain);
|
||||
let isSwarm = await isSwarmNode(remote.domain);
|
||||
if (!isSwarm) {
|
||||
const discovery = await discoverNode(remote.domain);
|
||||
isSwarm = discovery.success;
|
||||
}
|
||||
|
||||
if (!isSwarm) {
|
||||
return NextResponse.json({ posts: [], message: 'Only Synapsis swarm nodes are supported' });
|
||||
}
|
||||
@@ -81,7 +87,12 @@ export async function GET(request: Request, context: RouteContext) {
|
||||
}
|
||||
|
||||
// Only fetch from swarm nodes
|
||||
const isSwarm = await isSwarmNode(remote.domain);
|
||||
let isSwarm = await isSwarmNode(remote.domain);
|
||||
if (!isSwarm) {
|
||||
const discovery = await discoverNode(remote.domain);
|
||||
isSwarm = discovery.success;
|
||||
}
|
||||
|
||||
if (!isSwarm) {
|
||||
return NextResponse.json({ posts: [], message: 'Only Synapsis swarm nodes are supported' });
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { eq, and } from 'drizzle-orm';
|
||||
import { getSession } from '@/lib/auth';
|
||||
import { db, users, follows } from '@/db';
|
||||
import { fetchSwarmUserProfile, isSwarmNode } from '@/lib/swarm/interactions';
|
||||
import { discoverNode } from '@/lib/swarm/discovery';
|
||||
|
||||
type RouteContext = { params: Promise<{ handle: string }> };
|
||||
|
||||
@@ -40,7 +41,12 @@ export async function GET(request: Request, context: RouteContext) {
|
||||
if (!user || isRemotePlaceholder) {
|
||||
if (remoteHandle && remoteDomain) {
|
||||
// Only fetch from swarm nodes
|
||||
const isSwarm = await isSwarmNode(remoteDomain);
|
||||
let isSwarm = await isSwarmNode(remoteDomain);
|
||||
if (!isSwarm) {
|
||||
const discovery = await discoverNode(remoteDomain);
|
||||
isSwarm = discovery.success;
|
||||
}
|
||||
|
||||
if (isSwarm) {
|
||||
const profileData = await fetchSwarmUserProfile(remoteHandle, remoteDomain, 0);
|
||||
if (profileData?.profile) {
|
||||
|
||||
Reference in New Issue
Block a user