Skip to content

Commit

Permalink
Merge pull request #7 from nacika-ins/fix/remove-notes-for-misskey
Browse files Browse the repository at this point in the history
fix: Prepare container for home use.
  • Loading branch information
nacika-ins authored Feb 18, 2024
2 parents 19ed90f + ff9e6e7 commit 0ebe3fb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 37 deletions.
21 changes: 11 additions & 10 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use client';

import { NextPage } from 'next';
import React from 'react';
import { SettingContainer } from '@/components/organisms/SettingContainer';
import { HomeContainer } from '@/components/organisms/HomeContainer';

export default function Home() {
return (
<main className="relative py-6 lg:gap-10 lg:py-8">
<div className="container flex-1">
<SettingContainer />
</div>
</main>
);
}
const Page: NextPage = () => (
<main className="relative py-6 lg:gap-10 lg:py-8">
<div className="container flex-1">
<HomeContainer />
</div>
</main>
);

export default Page;
23 changes: 23 additions & 0 deletions components/organisms/HomeContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { FC } from 'react';
import { SettingsNav } from '@/components/molecules/SettingsNav';
import { Separator } from '@/components/ui/separator';

export const HomeContainer: FC = () => (
<div className="hidden space-y-6 p-10 pb-16 md:block">
<div className="space-y-0.5">
<h2 className="text-2xl font-bold tracking-tight">Settings</h2>
<p className="text-muted-foreground">
Automated anti-spam settings are available.
</p>
</div>
<Separator className="my-6" />
<div className="flex flex-col space-y-8 lg:flex-row lg:space-x-12 lg:space-y-0">
<aside className="-mx-4 lg:w-1/5">
<SettingsNav />
</aside>
<div className="flex-1 lg:max-w-2xl">
Please select a menu
</div>
</div>
</div>
);
30 changes: 3 additions & 27 deletions components/organisms/SettingContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,20 @@ import { SettingsNav } from '@/components/molecules/SettingsNav';
import { useFieldArray, useForm } from 'react-hook-form';

import { Button } from '@/components/ui/button';
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from '@/components/ui/form';
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { z } from 'zod';
import { zodResolver } from '@hookform/resolvers/zod';
import { toast } from '@/components/ui/use-toast';
import { cn } from '@/lib/utils';

import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from '@/components/ui/card';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';

import { Switch } from '@/components/ui/switch';

import Link from 'next/link';
import { Textarea } from '@/components/ui/textarea';
import { Separator } from '@/components/ui/separator';
import { Cross1Icon, RocketIcon } from '@radix-ui/react-icons';

import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { formSchema } from '@/app/automatic-spam-reporting/formSchema';
import { get, update } from '@/app/automatic-spam-reporting/actions';
import { Skeleton } from '@/components/ui/skeleton';
Expand Down
18 changes: 18 additions & 0 deletions features/batch/misskey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ const suspendUser = async ({ provider, userId }: { provider: TargetProvider, use
return [];
});

const deleteNote = async ({ provider, noteId }: { provider: TargetProvider, noteId: string; }) =>
axios.post<void>(`${provider.apiEndpoint}/notes/delete`?.replace('//', '/'), {
i: provider.adminApiToken,
noteId,
}, {
headers: {
Authorization: `Bearer ${provider.apiToken}`,
'Content-Type': 'application/json',
},
}).then((res) => res.data).catch((err) => {
console.debug('err =', err.response?.data);
return [];
});

export const execMisskey = async (provider: TargetProvider, spamTexts: string[], lastChecked: Date | null | undefined) => {

// const offsetDate = dayjs((lastChecked ? dayjs(lastChecked)
Expand Down Expand Up @@ -187,6 +201,10 @@ export const execMisskey = async (provider: TargetProvider, spamTexts: string[],
throw new Error('Target User ID is not found');
}

// Delete note ( When 200OK, no value is returned )
console.debug('[deleteNote] noteId =', notification.note?.id);
await retry(() => deleteNote({ provider, noteId: notification.note?.id }));

// Suspend User ( When 200OK, no value is returned )
console.debug('[suspendUser] targetUserId =', targetUserId);
await retry(() => suspendUser({ provider, userId: targetUserId }));
Expand Down

0 comments on commit 0ebe3fb

Please sign in to comment.