feat: add torbox migration

This commit is contained in:
Zamitto 2025-01-11 17:52:48 -03:00
parent abb16e7736
commit db2e31b8cc
6 changed files with 28 additions and 3 deletions

View File

@ -20,6 +20,9 @@ export class UserPreferences {
@Column("text", { nullable: true })
realDebridApiToken: string | null;
@Column("text", { nullable: true })
torBoxApiToken: string | null;
@Column("boolean", { default: false })
downloadNotificationsEnabled: boolean;

View File

@ -17,6 +17,7 @@ import { AddShouldSeedColumn } from "./migrations/20241108200154_add_should_seed
import { AddSeedAfterDownloadColumn } from "./migrations/20241108201806_add_seed_after_download";
import { AddHiddenAchievementDescriptionColumn } from "./migrations/20241216140633_add_hidden_achievement_description_column ";
import { AddLaunchOptionsColumnToGame } from "./migrations/20241226044022_add_launch_options_column_to_game";
import { AddTorBoxApiToken } from "./migrations/20250111182229_add_torbox_api_token_column";
export type HydraMigration = Knex.Migration & { name: string };
@ -39,6 +40,7 @@ class MigrationSource implements Knex.MigrationSource<HydraMigration> {
AddSeedAfterDownloadColumn,
AddHiddenAchievementDescriptionColumn,
AddLaunchOptionsColumnToGame,
AddTorBoxApiToken,
]);
}
getMigrationName(migration: HydraMigration): string {

View File

@ -19,10 +19,12 @@ const loadState = async (userPreferences: UserPreferences | null) => {
Aria2.spawn();
if (userPreferences?.realDebridApiToken) {
RealDebridClient.authorize(userPreferences?.realDebridApiToken);
RealDebridClient.authorize(userPreferences.realDebridApiToken);
}
TorBoxClient.authorize("7371d5ec-52fa-4b87-9052-0c8c96d947cc");
if (userPreferences?.torBoxApiToken) {
TorBoxClient.authorize(userPreferences?.torBoxApiToken);
}
Ludusavi.addManifestToLudusaviConfig();

View File

@ -0,0 +1,17 @@
import type { HydraMigration } from "@main/knex-client";
import type { Knex } from "knex";
export const AddTorBoxApiToken: HydraMigration = {
name: "AddTorBoxApiToken",
up: (knex: Knex) => {
return knex.schema.alterTable("user_preferences", (table) => {
return table.string("torBoxApiToken").nullable();
});
},
down: async (knex: Knex) => {
return knex.schema.alterTable("user_preferences", (table) => {
return table.dropColumn("torBoxApiToken");
});
},
};

View File

@ -19,7 +19,7 @@ export class TorBoxClient {
Authorization: `Bearer ${apiToken}`,
},
});
this.apiToken = "7371d5ec-52fa-4b87-9052-0c8c96d947cc";
this.apiToken = apiToken;
}
static async addMagnet(magnet: string) {

View File

@ -163,6 +163,7 @@ export interface UserPreferences {
repackUpdatesNotificationsEnabled: boolean;
achievementNotificationsEnabled: boolean;
realDebridApiToken: string | null;
torboxApiToken: string | null;
preferQuitInsteadOfHiding: boolean;
runAtStartup: boolean;
startMinimized: boolean;