mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat(web): license UI (#11182)
This commit is contained in:
parent
88f62087fd
commit
ef0e1a81b9
39 changed files with 1157 additions and 148 deletions
26
web/src/lib/utils/license-utils.ts
Normal file
26
web/src/lib/utils/license-utils.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { PUBLIC_IMMICH_BUY_HOST, PUBLIC_IMMICH_PAY_HOST } from '$env/static/public';
|
||||
import type { ImmichLicense } from '$lib/constants';
|
||||
import { serverConfig } from '$lib/stores/server-config.store';
|
||||
import { setServerLicense, setUserLicense, type LicenseResponseDto } from '@immich/sdk';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export const activateLicense = async (licenseKey: string, activationKey: string): Promise<LicenseResponseDto> => {
|
||||
const isServerKey = licenseKey.search('IMSV') !== -1;
|
||||
const licenseKeyDto = { licenseKey, activationKey };
|
||||
return isServerKey ? setServerLicense({ licenseKeyDto }) : setUserLicense({ licenseKeyDto });
|
||||
};
|
||||
|
||||
export const getActivationKey = async (licenseKey: string): Promise<string> => {
|
||||
const response = await fetch(new URL(`/api/v1/activate/${licenseKey}`, PUBLIC_IMMICH_PAY_HOST).href);
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch activation key');
|
||||
}
|
||||
return response.text();
|
||||
};
|
||||
|
||||
export const getLicenseLink = (license: ImmichLicense) => {
|
||||
const url = new URL('/', PUBLIC_IMMICH_BUY_HOST);
|
||||
url.searchParams.append('productId', license);
|
||||
url.searchParams.append('instanceUrl', get(serverConfig).externalDomain || window.origin);
|
||||
return url.href;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue