feat: update checker based gh releases

This commit is contained in:
Huskydog9988
2025-05-14 16:07:25 -04:00
parent 8b57ef9dd5
commit 3fbcc2e886
9 changed files with 205 additions and 7 deletions
+14
View File
@@ -1,6 +1,12 @@
class SystemConfig {
private libraryFolder = process.env.LIBRARY ?? "./.data/library";
private dataFolder = process.env.DATA ?? "./.data/data";
private dropVersion = "v0.3.0";
private checkForUpdates =
process.env.CHECK_FOR_UPDATES !== undefined &&
process.env.CHECK_FOR_UPDATES.toLocaleLowerCase() === "true"
? true
: false;
getLibraryFolder() {
return this.libraryFolder;
@@ -9,6 +15,14 @@ class SystemConfig {
getDataFolder() {
return this.dataFolder;
}
getDropVersion() {
return this.dropVersion;
}
shouldCheckForUpdates() {
return this.checkForUpdates;
}
}
export const systemConfig = new SystemConfig();
+2 -1
View File
@@ -10,6 +10,7 @@ import type {
} from "./types";
import { ObjectTransactionalHandler } from "../objects/transactional";
import { PriorityListIndexed } from "../utils/prioritylist";
import { systemConfig } from "../config/sys-conf";
export class MissingMetadataProviderConfig extends Error {
private providerName: string;
@@ -25,7 +26,7 @@ export class MissingMetadataProviderConfig extends Error {
}
// TODO: add useragent to all outbound api calls (best practice)
export const DropUserAgent = "Drop/0.2";
export const DropUserAgent = `Drop/${systemConfig.getDropVersion()}`;
export abstract class MetadataProvider {
abstract name(): string;
+31 -5
View File
@@ -9,6 +9,7 @@ Design goals:
import type { Notification } from "~/prisma/client";
import prisma from "../db/database";
// TODO: document notification action format
export type NotificationCreateArgs = Pick<
Notification,
"title" | "description" | "actions" | "nonce"
@@ -61,14 +62,18 @@ class NotificationSystem {
throw new Error("No nonce in notificationCreateArgs");
const notification = await prisma.notification.upsert({
where: {
nonce: notificationCreateArgs.nonce,
userId_nonce: {
nonce: notificationCreateArgs.nonce,
userId,
},
},
update: {
userId: userId,
// we don't need to update the userid right?
// userId: userId,
...notificationCreateArgs,
},
create: {
userId: userId,
userId,
...notificationCreateArgs,
},
});
@@ -84,13 +89,34 @@ class NotificationSystem {
},
});
const res: Promise<void>[] = [];
for (const user of users) {
await this.push(user.id, notificationCreateArgs);
res.push(this.push(user.id, notificationCreateArgs));
}
// wait for all notifications to pass
await Promise.all(res);
}
async systemPush(notificationCreateArgs: NotificationCreateArgs) {
return await this.push("system", notificationCreateArgs);
await this.push("system", notificationCreateArgs);
}
async pushAllAdmins(notificationCreateArgs: NotificationCreateArgs) {
const users = await prisma.user.findMany({
where: {
admin: true,
},
select: {
id: true,
},
});
const res: Promise<void>[] = [];
for (const user of users) {
res.push(this.push(user.id, notificationCreateArgs));
}
// wait for all notifications to pass
await Promise.all(res);
}
}