mirror of
https://github.com/movie-web/backend.git
synced 2025-09-13 14:53:25 +00:00
Merge pull request #28 from qtchaos/proxy-syncing
Add proxyUrls column to UserSettings model
This commit is contained in:
@@ -483,6 +483,15 @@
|
|||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "string"
|
"mappedType": "string"
|
||||||
|
},
|
||||||
|
"proxy_urls": {
|
||||||
|
"name": "proxy_urls",
|
||||||
|
"type": "text[]",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"mappedType": "array"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"name": "user_settings",
|
"name": "user_settings",
|
||||||
|
13
src/db/migrations/Migration20231229214215.ts
Normal file
13
src/db/migrations/Migration20231229214215.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20231229214215 extends Migration {
|
||||||
|
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql('alter table "user_settings" add column "proxy_urls" text[] null;');
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql('alter table "user_settings" drop column "proxy_urls";');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
|
import { ArrayType, Entity, PrimaryKey, Property } from '@mikro-orm/core';
|
||||||
|
|
||||||
@Entity({ tableName: 'user_settings' })
|
@Entity({ tableName: 'user_settings' })
|
||||||
export class UserSettings {
|
export class UserSettings {
|
||||||
@@ -13,6 +13,9 @@ export class UserSettings {
|
|||||||
|
|
||||||
@Property({ name: 'default_subtitle_language', nullable: true })
|
@Property({ name: 'default_subtitle_language', nullable: true })
|
||||||
defaultSubtitleLanguage?: string | null;
|
defaultSubtitleLanguage?: string | null;
|
||||||
|
|
||||||
|
@Property({ name: 'proxy_urls', type: ArrayType, nullable: true })
|
||||||
|
proxyUrls?: string[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserSettingsDTO {
|
export interface UserSettingsDTO {
|
||||||
@@ -20,6 +23,7 @@ export interface UserSettingsDTO {
|
|||||||
applicationTheme?: string | null;
|
applicationTheme?: string | null;
|
||||||
applicationLanguage?: string | null;
|
applicationLanguage?: string | null;
|
||||||
defaultSubtitleLanguage?: string | null;
|
defaultSubtitleLanguage?: string | null;
|
||||||
|
proxyUrls?: string[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatUserSettings(
|
export function formatUserSettings(
|
||||||
@@ -30,5 +34,6 @@ export function formatUserSettings(
|
|||||||
applicationTheme: userSettings.applicationTheme,
|
applicationTheme: userSettings.applicationTheme,
|
||||||
applicationLanguage: userSettings.applicationLanguage,
|
applicationLanguage: userSettings.applicationLanguage,
|
||||||
defaultSubtitleLanguage: userSettings.defaultSubtitleLanguage,
|
defaultSubtitleLanguage: userSettings.defaultSubtitleLanguage,
|
||||||
|
proxyUrls: userSettings.proxyUrls,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,7 @@ export const userSettingsRouter = makeRouter((app) => {
|
|||||||
applicationLanguage: z.string().nullable().optional(),
|
applicationLanguage: z.string().nullable().optional(),
|
||||||
applicationTheme: z.string().nullable().optional(),
|
applicationTheme: z.string().nullable().optional(),
|
||||||
defaultSubtitleLanguage: z.string().nullable().optional(),
|
defaultSubtitleLanguage: z.string().nullable().optional(),
|
||||||
|
proxyUrls: z.string().array().nullable().optional(),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -64,6 +65,7 @@ export const userSettingsRouter = makeRouter((app) => {
|
|||||||
settings.defaultSubtitleLanguage = body.defaultSubtitleLanguage;
|
settings.defaultSubtitleLanguage = body.defaultSubtitleLanguage;
|
||||||
if (body.applicationTheme !== undefined)
|
if (body.applicationTheme !== undefined)
|
||||||
settings.applicationTheme = body.applicationTheme;
|
settings.applicationTheme = body.applicationTheme;
|
||||||
|
if (body.proxyUrls !== undefined) settings.proxyUrls = body.proxyUrls;
|
||||||
|
|
||||||
await em.persistAndFlush(settings);
|
await em.persistAndFlush(settings);
|
||||||
return formatUserSettings(settings);
|
return formatUserSettings(settings);
|
||||||
|
Reference in New Issue
Block a user