mirror of
https://github.com/immich-app/immich.git
synced 2026-02-12 11:58:15 +03:00
feat(server): user preferences (#9736)
* refactor(server): user endpoints * feat(server): user preferences * mobile: user preference * wording --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@@ -432,6 +432,98 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/admin/users/{id}/preferences": {
|
||||
"get": {
|
||||
"operationId": "getUserPreferencesAdmin",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"format": "uuid",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UserPreferencesResponseDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
},
|
||||
{
|
||||
"cookie": []
|
||||
},
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"User"
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"operationId": "updateUserPreferencesAdmin",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"format": "uuid",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UserPreferencesUpdateDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UserPreferencesResponseDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
},
|
||||
{
|
||||
"cookie": []
|
||||
},
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"User"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/admin/users/{id}/restore": {
|
||||
"post": {
|
||||
"operationId": "restoreUserAdmin",
|
||||
@@ -6403,6 +6495,78 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/users/me/preferences": {
|
||||
"get": {
|
||||
"operationId": "getMyPreferences",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UserPreferencesResponseDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
},
|
||||
{
|
||||
"cookie": []
|
||||
},
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"User"
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"operationId": "updateMyPreferences",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UserPreferencesUpdateDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UserPreferencesResponseDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
},
|
||||
{
|
||||
"cookie": []
|
||||
},
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"User"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/users/profile-image": {
|
||||
"delete": {
|
||||
"operationId": "deleteProfileImage",
|
||||
@@ -7621,6 +7785,25 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"AvatarResponse": {
|
||||
"properties": {
|
||||
"color": {
|
||||
"$ref": "#/components/schemas/UserAvatarColor"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"color"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"AvatarUpdate": {
|
||||
"properties": {
|
||||
"color": {
|
||||
"$ref": "#/components/schemas/UserAvatarColor"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"BulkIdResponseDto": {
|
||||
"properties": {
|
||||
"error": {
|
||||
@@ -8584,6 +8767,17 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"MemoryResponse": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"enabled"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"MemoryResponseDto": {
|
||||
"properties": {
|
||||
"assets": {
|
||||
@@ -8650,6 +8844,14 @@
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"MemoryUpdate": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"MemoryUpdateDto": {
|
||||
"properties": {
|
||||
"isSaved": {
|
||||
@@ -10878,9 +11080,6 @@
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"memoriesEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -10942,9 +11141,6 @@
|
||||
"isAdmin": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"memoriesEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -11000,15 +11196,9 @@
|
||||
},
|
||||
"UserAdminUpdateDto": {
|
||||
"properties": {
|
||||
"avatarColor": {
|
||||
"$ref": "#/components/schemas/UserAvatarColor"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"memoriesEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -11046,6 +11236,32 @@
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"UserPreferencesResponseDto": {
|
||||
"properties": {
|
||||
"avatar": {
|
||||
"$ref": "#/components/schemas/AvatarResponse"
|
||||
},
|
||||
"memories": {
|
||||
"$ref": "#/components/schemas/MemoryResponse"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"avatar",
|
||||
"memories"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"UserPreferencesUpdateDto": {
|
||||
"properties": {
|
||||
"avatar": {
|
||||
"$ref": "#/components/schemas/AvatarUpdate"
|
||||
},
|
||||
"memories": {
|
||||
"$ref": "#/components/schemas/MemoryUpdate"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"UserResponseDto": {
|
||||
"properties": {
|
||||
"avatarColor": {
|
||||
@@ -11083,15 +11299,9 @@
|
||||
},
|
||||
"UserUpdateMeDto": {
|
||||
"properties": {
|
||||
"avatarColor": {
|
||||
"$ref": "#/components/schemas/UserAvatarColor"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"memoriesEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -13,22 +13,13 @@ npm i --save @immich/sdk
|
||||
For a more detailed example, check out the [`@immich/cli`](https://github.com/immich-app/immich/tree/main/cli).
|
||||
|
||||
```typescript
|
||||
<<<<<<< HEAD
|
||||
import { getAllAlbums, getAllAssets, getMyUser, init } from "@immich/sdk";
|
||||
=======
|
||||
import { getAllAlbums, getMyUserInfo, init } from "@immich/sdk";
|
||||
>>>>>>> e7c8501930a988dfb6c23ce1c48b0beb076a58c2
|
||||
import { getAllAlbums, getMyUser, init } from "@immich/sdk";
|
||||
|
||||
const API_KEY = "<API_KEY>"; // process.env.IMMICH_API_KEY
|
||||
|
||||
init({ baseUrl: "https://demo.immich.app/api", apiKey: API_KEY });
|
||||
|
||||
<<<<<<< HEAD
|
||||
const user = await getMyUser();
|
||||
const assets = await getAllAssets({ take: 1000 });
|
||||
=======
|
||||
const user = await getMyUserInfo();
|
||||
>>>>>>> e7c8501930a988dfb6c23ce1c48b0beb076a58c2
|
||||
const albums = await getAllAlbums({});
|
||||
|
||||
console.log({ user, albums });
|
||||
|
||||
@@ -45,7 +45,6 @@ export type UserAdminResponseDto = {
|
||||
email: string;
|
||||
id: string;
|
||||
isAdmin: boolean;
|
||||
memoriesEnabled?: boolean;
|
||||
name: string;
|
||||
oauthId: string;
|
||||
profileImagePath: string;
|
||||
@@ -58,7 +57,6 @@ export type UserAdminResponseDto = {
|
||||
};
|
||||
export type UserAdminCreateDto = {
|
||||
email: string;
|
||||
memoriesEnabled?: boolean;
|
||||
name: string;
|
||||
notify?: boolean;
|
||||
password: string;
|
||||
@@ -70,15 +68,33 @@ export type UserAdminDeleteDto = {
|
||||
force?: boolean;
|
||||
};
|
||||
export type UserAdminUpdateDto = {
|
||||
avatarColor?: UserAvatarColor;
|
||||
email?: string;
|
||||
memoriesEnabled?: boolean;
|
||||
name?: string;
|
||||
password?: string;
|
||||
quotaSizeInBytes?: number | null;
|
||||
shouldChangePassword?: boolean;
|
||||
storageLabel?: string | null;
|
||||
};
|
||||
export type AvatarResponse = {
|
||||
color: UserAvatarColor;
|
||||
};
|
||||
export type MemoryResponse = {
|
||||
enabled: boolean;
|
||||
};
|
||||
export type UserPreferencesResponseDto = {
|
||||
avatar: AvatarResponse;
|
||||
memories: MemoryResponse;
|
||||
};
|
||||
export type AvatarUpdate = {
|
||||
color?: UserAvatarColor;
|
||||
};
|
||||
export type MemoryUpdate = {
|
||||
enabled?: boolean;
|
||||
};
|
||||
export type UserPreferencesUpdateDto = {
|
||||
avatar?: AvatarUpdate;
|
||||
memories?: MemoryUpdate;
|
||||
};
|
||||
export type AlbumUserResponseDto = {
|
||||
role: AlbumUserRole;
|
||||
user: UserResponseDto;
|
||||
@@ -1073,9 +1089,7 @@ export type TimeBucketResponseDto = {
|
||||
timeBucket: string;
|
||||
};
|
||||
export type UserUpdateMeDto = {
|
||||
avatarColor?: UserAvatarColor;
|
||||
email?: string;
|
||||
memoriesEnabled?: boolean;
|
||||
name?: string;
|
||||
password?: string;
|
||||
};
|
||||
@@ -1200,6 +1214,29 @@ export function updateUserAdmin({ id, userAdminUpdateDto }: {
|
||||
body: userAdminUpdateDto
|
||||
})));
|
||||
}
|
||||
export function getUserPreferencesAdmin({ id }: {
|
||||
id: string;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: UserPreferencesResponseDto;
|
||||
}>(`/admin/users/${encodeURIComponent(id)}/preferences`, {
|
||||
...opts
|
||||
}));
|
||||
}
|
||||
export function updateUserPreferencesAdmin({ id, userPreferencesUpdateDto }: {
|
||||
id: string;
|
||||
userPreferencesUpdateDto: UserPreferencesUpdateDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: UserPreferencesResponseDto;
|
||||
}>(`/admin/users/${encodeURIComponent(id)}/preferences`, oazapfts.json({
|
||||
...opts,
|
||||
method: "PUT",
|
||||
body: userPreferencesUpdateDto
|
||||
})));
|
||||
}
|
||||
export function restoreUserAdmin({ id }: {
|
||||
id: string;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
@@ -2780,6 +2817,26 @@ export function updateMyUser({ userUpdateMeDto }: {
|
||||
body: userUpdateMeDto
|
||||
})));
|
||||
}
|
||||
export function getMyPreferences(opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: UserPreferencesResponseDto;
|
||||
}>("/users/me/preferences", {
|
||||
...opts
|
||||
}));
|
||||
}
|
||||
export function updateMyPreferences({ userPreferencesUpdateDto }: {
|
||||
userPreferencesUpdateDto: UserPreferencesUpdateDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: UserPreferencesResponseDto;
|
||||
}>("/users/me/preferences", oazapfts.json({
|
||||
...opts,
|
||||
method: "PUT",
|
||||
body: userPreferencesUpdateDto
|
||||
})));
|
||||
}
|
||||
export function deleteProfileImage(opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchText("/users/profile-image", {
|
||||
...opts,
|
||||
|
||||
Reference in New Issue
Block a user