フォルダ構成だけ変えた
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import { meApi, ueuse } from "../../src/types/types";
|
||||
import config from "../../config.js";
|
||||
import { Reply } from "./main.js";
|
||||
|
||||
export default async function Delete(data: ueuse) {
|
||||
const meReq = await fetch(`${config.uwuzu.host}/api/me/`, {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
body: JSON.stringify({
|
||||
token: config.uwuzu.apiToken,
|
||||
}),
|
||||
});
|
||||
|
||||
if (meReq.status < 200 || meReq.status > 299) {
|
||||
return;
|
||||
}
|
||||
|
||||
const me: meApi = await meReq.json();
|
||||
|
||||
const replyUeuseReq = await fetch(`${config.uwuzu.host}/api/ueuse/get`, {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
body: JSON.stringify({
|
||||
token: config.uwuzu.apiToken,
|
||||
uniqid: data.replyid,
|
||||
}),
|
||||
});
|
||||
|
||||
if (replyUeuseReq.status < 200 || replyUeuseReq.status > 299) {
|
||||
return;
|
||||
}
|
||||
|
||||
const replyUeuse: ueuse = (await replyUeuseReq.json())["0"];
|
||||
|
||||
if (me.userid === replyUeuse.account.userid) {
|
||||
const ueuseDeleteReq = await fetch(`${config.uwuzu.host}/api/ueuse/delete`, {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
body: JSON.stringify({
|
||||
token: config.uwuzu.apiToken,
|
||||
uniqid: data.replyid,
|
||||
}),
|
||||
});
|
||||
|
||||
if (ueuseDeleteReq.status < 200 || ueuseDeleteReq.status > 299) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ueuseDelete = await ueuseDeleteReq.json();
|
||||
|
||||
console.log("削除:", ueuseDelete);
|
||||
|
||||
if (ueuseDelete.success === true) {
|
||||
console.log("削除通知:", await Reply(`
|
||||
対象のユーズを削除しました。
|
||||
`, data.uniqid));
|
||||
} else {
|
||||
console.log("削除失敗通知:", await Reply(`
|
||||
対象のユーズを削除できませんでした。
|
||||
`, data.uniqid));
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
console.log("削除失敗通知(他人):", await Reply(`
|
||||
削除するユーズが${me.username}のものではありません。
|
||||
そのため削除できませんでした。
|
||||
`, data.uniqid));
|
||||
return;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user