mirror of
https://github.com/captbaritone/webamp.git
synced 2026-08-03 23:43:28 +00:00
Report ia sync to Discord
This commit is contained in:
parent
066c90688c
commit
3c407afae5
4 changed files with 30 additions and 4 deletions
|
|
@ -101,6 +101,24 @@ export default class DiscordEventHandler {
|
|||
await dest.send(message);
|
||||
break;
|
||||
}
|
||||
|
||||
case "SYNCED_TO_ARCHIVE": {
|
||||
const dest = await this.getChannel(Config.SKIN_UPLOADS_CHANNEL_ID);
|
||||
|
||||
const message = `Synced skins to archive.org. Success: ${action.successes.toLocaleString()} Errors: ${action.errors.toLocaleString()}.`;
|
||||
|
||||
await dest.send(message);
|
||||
break;
|
||||
}
|
||||
|
||||
case "STARTED_SYNC_TO_ARCHIVE": {
|
||||
const dest = await this.getChannel(Config.SKIN_UPLOADS_CHANNEL_ID);
|
||||
|
||||
const message = `Starting sync to archive.org. Found ${action.count.toLocaleString()} to sync.`;
|
||||
|
||||
await dest.send(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ export type ApiAction =
|
|||
| { type: "CLASSIC_SKIN_UPLOADED"; md5: string }
|
||||
| { type: "MODERN_SKIN_UPLOADED"; md5: string }
|
||||
| { type: "SKIN_UPLOAD_ERROR"; uploadId: string; message: string }
|
||||
| { type: "GOT_FEEDBACK"; message: string; email?: string, url?: string };
|
||||
| { type: "GOT_FEEDBACK"; message: string; email?: string; url?: string }
|
||||
| { type: "SYNCED_TO_ARCHIVE"; successes: number; errors: number }
|
||||
| { type: "STARTED_SYNC_TO_ARCHIVE"; count: number };
|
||||
|
||||
export type EventHandler = (event: ApiAction) => void;
|
||||
export type Logger = {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ async function main() {
|
|||
await syncFromArchive();
|
||||
break;
|
||||
case "sync-ia":
|
||||
await syncWithArchive();
|
||||
await syncWithArchive(handler);
|
||||
break;
|
||||
case "integity-check":
|
||||
await integrityCheck();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import SkinModel from "../data/SkinModel";
|
|||
import util from "util";
|
||||
import * as Parallel from "async-parallel";
|
||||
import IaItemModel from "../data/IaItemModel";
|
||||
import DiscordEventHandler from "../api/DiscordEventHandler";
|
||||
const exec = util.promisify(child_process.exec);
|
||||
|
||||
const CONCURRENT = 1;
|
||||
|
|
@ -105,7 +106,7 @@ export async function archive(skin: SkinModel): Promise<string> {
|
|||
return identifier;
|
||||
}
|
||||
|
||||
export async function syncWithArchive() {
|
||||
export async function syncWithArchive(handler: DiscordEventHandler) {
|
||||
const ctx = new UserContext();
|
||||
console.log("Checking which new skins we have...");
|
||||
const unarchived = await knex("skins")
|
||||
|
|
@ -113,7 +114,7 @@ export async function syncWithArchive() {
|
|||
.where({ "ia_items.id": null, skin_type: 1 })
|
||||
.select("skins.md5");
|
||||
|
||||
console.log(`Found ${unarchived.length} skins to upload`);
|
||||
handler.handle({ type: "STARTED_SYNC_TO_ARCHIVE", count: unarchived.length });
|
||||
|
||||
let successCount = 0;
|
||||
let errorCount = 0;
|
||||
|
|
@ -150,6 +151,11 @@ export async function syncWithArchive() {
|
|||
},
|
||||
CONCURRENT
|
||||
);
|
||||
await handler.handle({
|
||||
type: "SYNCED_TO_ARCHIVE",
|
||||
successes: successCount,
|
||||
errors: errorCount,
|
||||
});
|
||||
console.log(`Job complete: ${successCount} success, ${errorCount} errors`);
|
||||
}
|
||||
// Build the URL to get all wsz files
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue