mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-24 02:27:37 +00:00
Add more types
This commit is contained in:
parent
88a9a07b73
commit
961ceaf605
2 changed files with 25 additions and 15 deletions
|
|
@ -1,10 +1,12 @@
|
|||
const fs = require("fs");
|
||||
const md5Buffer = require("md5");
|
||||
const Skins = require("./data/skins");
|
||||
const S3 = require("./s3");
|
||||
const Shooter = require("./shooter");
|
||||
const temp = require("temp").track();
|
||||
const Analyser = require("./analyser");
|
||||
import * as Skins from "./data/skins";
|
||||
import fs from "fs";
|
||||
import md5Buffer from "md5";
|
||||
import S3 from "./s3";
|
||||
import Shooter from "./shooter";
|
||||
import _temp from "temp";
|
||||
import Analyser from "./analyser";
|
||||
|
||||
const temp = _temp.track();
|
||||
|
||||
// TODO
|
||||
// Extract the readme
|
||||
|
|
@ -12,7 +14,15 @@ const Analyser = require("./analyser");
|
|||
// Upload to Internet Archive
|
||||
// Store the Internet Archive item name
|
||||
// Construct IA Webamp UR
|
||||
async function addSkinFromBuffer(buffer, filePath, uploader) {
|
||||
type Result =
|
||||
| { md5: string; status: "FOUND" }
|
||||
| { md5: string; status: "ADDED"; averageColor: string };
|
||||
|
||||
async function addSkinFromBuffer(
|
||||
buffer: Buffer,
|
||||
filePath: string,
|
||||
uploader: string
|
||||
): Promise<Result> {
|
||||
const md5 = md5Buffer(buffer);
|
||||
const skin = await Skins.getSkinByMd5(md5);
|
||||
if (skin != null) {
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
const db = require("../db");
|
||||
const path = require("path");
|
||||
import db from "../db";
|
||||
import path from "path";
|
||||
import S3 from "../s3";
|
||||
import logger from "../logger";
|
||||
const skins = db.get("skins");
|
||||
const iaItems = db.get("internetArchiveItems");
|
||||
const S3 = require("../s3");
|
||||
const logger = require("../logger");
|
||||
|
||||
type TweetStatus = "APPROVED" | "REJECTED" | "TWEETED" | "UNREVIEWED";
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ async function getProp<T extends keyof DBSkinRecord>(
|
|||
return value == null ? null : value;
|
||||
}
|
||||
|
||||
async function addSkin({ md5, filePath, uploader, averageColor }) {
|
||||
export async function addSkin({ md5, filePath, uploader, averageColor }) {
|
||||
skins.insert({
|
||||
md5,
|
||||
type: "CLASSIC",
|
||||
|
|
@ -133,7 +133,7 @@ async function getMd5ByAnything(anything: string): Promise<string | null> {
|
|||
return imageHashMd5;
|
||||
}
|
||||
|
||||
async function getSkinByMd5(md5) {
|
||||
export async function getSkinByMd5(md5: string) {
|
||||
const skin = await skins.findOne({ md5, type: "CLASSIC" });
|
||||
if (skin == null) {
|
||||
logger.warn("Could not find skin in database", { md5, alert: true });
|
||||
|
|
@ -262,7 +262,7 @@ async function getStats(): Promise<{
|
|||
const approved = await skins.count({ approved: true });
|
||||
const rejected = await skins.count({ rejected: true });
|
||||
const tweeted = await skins.count({ tweeted: true });
|
||||
const tweetable = await getTweetableSkinCount();
|
||||
const tweetable = getTweetableSkinCount();
|
||||
return { approved, rejected, tweeted, tweetable };
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue