Add auto updates and tighten reply feeds

This commit is contained in:
cyph3rasi
2026-03-08 19:22:18 -07:00
parent 5f21ea8e5d
commit 044196cfa7
7 changed files with 281 additions and 41 deletions
+25 -1
View File
@@ -1,7 +1,7 @@
import { NextResponse } from 'next/server';
import { requireAdmin } from '@/lib/auth/admin';
import { getCurrentBuildInfo, getLatestPublishedBuild, compareBuildVersions } from '@/lib/version';
import { getHostUpdaterStatus, triggerHostUpdate } from '@/lib/host-updater';
import { getHostUpdaterStatus, triggerHostUpdate, updateHostUpdaterConfig } from '@/lib/host-updater';
function isUpdateAvailable(currentVersion: string, latestVersion: string | null | undefined) {
if (!latestVersion) {
@@ -56,3 +56,27 @@ export async function POST() {
);
}
}
export async function PATCH(request: Request) {
try {
await requireAdmin();
const body = await request.json();
if (typeof body.autoUpdateEnabled !== 'boolean') {
return NextResponse.json({ error: 'autoUpdateEnabled must be a boolean' }, { status: 400 });
}
const result = await updateHostUpdaterConfig(body.autoUpdateEnabled);
return NextResponse.json(result);
} catch (error) {
if (error instanceof Error && error.message === 'Admin required') {
return NextResponse.json({ error: 'Admin required' }, { status: 403 });
}
console.error('[Admin Update] Config error:', error);
return NextResponse.json(
{ error: error instanceof Error ? error.message : 'Failed to update auto-update settings' },
{ status: 500 }
);
}
}
+3 -1
View File
@@ -735,7 +735,9 @@ export async function GET(request: Request) {
);
if (!profileData?.posts) return [];
return profileData.posts.map(post => ({
return profileData.posts
.filter((post: any) => !post.replyToId && !post.swarmReplyToId && !post.isReply)
.map(post => ({
id: `swarm:${domain}:${post.id}`,
content: post.content,
createdAt: new Date(post.createdAt),
+4 -2
View File
@@ -6,7 +6,7 @@
import { NextRequest, NextResponse } from 'next/server';
import { db, posts, users, media, nodes } from '@/db';
import { eq, desc, and } from 'drizzle-orm';
import { eq, desc, and, isNull } from 'drizzle-orm';
export interface SwarmUserProfile {
handle: string;
@@ -116,7 +116,9 @@ export async function GET(request: NextRequest, context: RouteContext) {
.where(
and(
eq(posts.userId, user.id),
eq(posts.isRemoved, false)
eq(posts.isRemoved, false),
isNull(posts.replyToId),
isNull(posts.swarmReplyToId)
)
)
.orderBy(desc(posts.createdAt))