mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-10 22:01:16 +00:00
Adds full Telegram ZIP ingestion pipeline: TDLib worker service scans source channels for archive files, deduplicates by content hash, extracts metadata, uploads to archive channel, and indexes in Postgres. Forum supergroups are scanned per-topic with topic names used as creator. Filename-based creator extraction (e.g. "Mammoth Factory - 2026-01.zip") serves as fallback. Includes admin UI for managing accounts/channels, simplified account setup (API credentials via env vars), auth code/password submission dialog, package browser with creator column, and live ingestion activity tracking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
103 lines
2.8 KiB
TypeScript
103 lines
2.8 KiB
TypeScript
"use client";
|
|
|
|
import { useTransition } from "react";
|
|
import { useForm } from "react-hook-form";
|
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
import { toast } from "sonner";
|
|
import {
|
|
telegramAccountSchema,
|
|
type TelegramAccountInput,
|
|
} from "@/schemas/telegram";
|
|
import { createAccount, updateAccount } from "../actions";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Input } from "@/components/ui/input";
|
|
import {
|
|
Form,
|
|
FormControl,
|
|
FormDescription,
|
|
FormField,
|
|
FormItem,
|
|
FormLabel,
|
|
FormMessage,
|
|
} from "@/components/ui/form";
|
|
import type { AccountRow } from "@/lib/telegram/admin-queries";
|
|
|
|
interface AccountFormProps {
|
|
account?: AccountRow;
|
|
onSuccess: () => void;
|
|
}
|
|
|
|
export function AccountForm({ account, onSuccess }: AccountFormProps) {
|
|
const [isPending, startTransition] = useTransition();
|
|
const isEditing = !!account;
|
|
|
|
const form = useForm<TelegramAccountInput>({
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
resolver: zodResolver(telegramAccountSchema) as any,
|
|
defaultValues: {
|
|
phone: account?.phone ?? "",
|
|
displayName: account?.displayName ?? "",
|
|
},
|
|
});
|
|
|
|
function onSubmit(values: TelegramAccountInput) {
|
|
startTransition(async () => {
|
|
const result = isEditing
|
|
? await updateAccount(account!.id, values)
|
|
: await createAccount(values);
|
|
|
|
if (!result.success) {
|
|
toast.error(result.error);
|
|
return;
|
|
}
|
|
|
|
toast.success(isEditing ? "Account updated" : "Account created");
|
|
form.reset();
|
|
onSuccess();
|
|
});
|
|
}
|
|
|
|
return (
|
|
<Form {...form}>
|
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
|
<FormField
|
|
control={form.control}
|
|
name="phone"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormLabel>Phone Number</FormLabel>
|
|
<FormControl>
|
|
<Input placeholder="+31612345678" {...field} />
|
|
</FormControl>
|
|
<FormDescription>
|
|
International format with country code
|
|
</FormDescription>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
|
|
<FormField
|
|
control={form.control}
|
|
name="displayName"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormLabel>Display Name</FormLabel>
|
|
<FormControl>
|
|
<Input placeholder="My Bot Account" {...field} />
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
|
|
<div className="flex justify-end gap-2">
|
|
<Button type="submit" disabled={isPending}>
|
|
{isPending ? "Saving..." : isEditing ? "Update" : "Create"}
|
|
</Button>
|
|
</div>
|
|
</form>
|
|
</Form>
|
|
);
|
|
}
|