mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
feat: filter by person
This commit is contained in:
+19
-46
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "immich-core",
|
||||
"version": "2.0.1",
|
||||
"version": "2.4.1 ",
|
||||
"title": "Immich Core",
|
||||
"description": "Core workflow capabilities for Immich",
|
||||
"author": "Immich Team",
|
||||
@@ -12,9 +12,7 @@
|
||||
"methodName": "filterFileName",
|
||||
"title": "Filter by filename",
|
||||
"description": "Filter assets by filename pattern using text matching or regular expressions",
|
||||
"supportedContexts": [
|
||||
"asset"
|
||||
],
|
||||
"supportedContexts": ["asset"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -26,11 +24,7 @@
|
||||
"matchType": {
|
||||
"type": "string",
|
||||
"title": "Match type",
|
||||
"enum": [
|
||||
"contains",
|
||||
"regex",
|
||||
"exact"
|
||||
],
|
||||
"enum": ["contains", "regex", "exact"],
|
||||
"default": "contains",
|
||||
"description": "Type of pattern matching to perform"
|
||||
},
|
||||
@@ -40,18 +34,14 @@
|
||||
"description": "Whether matching should be case-sensitive"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"pattern"
|
||||
]
|
||||
"required": ["pattern"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"methodName": "filterFileType",
|
||||
"title": "Filter by file type",
|
||||
"description": "Filter assets by file type",
|
||||
"supportedContexts": [
|
||||
"asset"
|
||||
],
|
||||
"supportedContexts": ["asset"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -60,26 +50,19 @@
|
||||
"title": "File types",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image",
|
||||
"video"
|
||||
]
|
||||
"enum": ["image", "video"]
|
||||
},
|
||||
"description": "Allowed file types"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"fileTypes"
|
||||
]
|
||||
"required": ["fileTypes"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"methodName": "filterPerson",
|
||||
"title": "Filter by person",
|
||||
"description": "Filter by detected person",
|
||||
"supportedContexts": [
|
||||
"person"
|
||||
],
|
||||
"description": "Filter assets by detected people in the photo",
|
||||
"supportedContexts": ["person"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -92,15 +75,14 @@
|
||||
"description": "List of person to match",
|
||||
"subType": "people-picker"
|
||||
},
|
||||
"matchAny": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Match any name (true) or require all names (false)"
|
||||
"matchMode": {
|
||||
"type": "string",
|
||||
"title": "Match mode",
|
||||
"enum": ["any", "all", "exact"],
|
||||
"default": "any"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"personIds"
|
||||
]
|
||||
"required": ["personIds"]
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -109,18 +91,14 @@
|
||||
"methodName": "actionArchive",
|
||||
"title": "Archive",
|
||||
"description": "Move the asset to archive",
|
||||
"supportedContexts": [
|
||||
"asset"
|
||||
],
|
||||
"supportedContexts": ["asset"],
|
||||
"schema": {}
|
||||
},
|
||||
{
|
||||
"methodName": "actionFavorite",
|
||||
"title": "Favorite",
|
||||
"description": "Mark the asset as favorite or unfavorite",
|
||||
"supportedContexts": [
|
||||
"asset"
|
||||
],
|
||||
"supportedContexts": ["asset"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -136,10 +114,7 @@
|
||||
"methodName": "actionAddToAlbum",
|
||||
"title": "Add to Album",
|
||||
"description": "Add the item to a specified album",
|
||||
"supportedContexts": [
|
||||
"asset",
|
||||
"person"
|
||||
],
|
||||
"supportedContexts": ["asset", "person"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -150,9 +125,7 @@
|
||||
"subType": "album-picker"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"albumId"
|
||||
]
|
||||
"required": ["albumId"]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
declare module 'main' {
|
||||
export function filterFileName(): I32;
|
||||
export function filterPerson(): I32;
|
||||
export function actionAddToAlbum(): I32;
|
||||
export function actionArchive(): I32;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,42 @@ function returnOutput(output: any) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function filterPerson() {
|
||||
const input = parseInput();
|
||||
|
||||
const { data, config } = input;
|
||||
const { personIds, matchMode } = config;
|
||||
|
||||
const faces = data.faces || [];
|
||||
|
||||
if (faces.length === 0) {
|
||||
return returnOutput({ passed: false });
|
||||
}
|
||||
|
||||
const assetPersonIds: string[] = faces
|
||||
.filter((face: { personId: string | null }) => face.personId !== null)
|
||||
.map((face: { personId: string }) => face.personId);
|
||||
|
||||
let passed = false;
|
||||
|
||||
if (!personIds || personIds.length === 0) {
|
||||
passed = true;
|
||||
} else if (matchMode === 'any') {
|
||||
passed = personIds.some((id: string) => assetPersonIds.includes(id));
|
||||
} else if (matchMode === 'all') {
|
||||
passed = personIds.every((id: string) => assetPersonIds.includes(id));
|
||||
} else if (matchMode === 'exact') {
|
||||
const uniquePersonIds = new Set(personIds);
|
||||
const uniqueAssetPersonIds = new Set(assetPersonIds);
|
||||
|
||||
passed =
|
||||
uniquePersonIds.size === uniqueAssetPersonIds.size &&
|
||||
personIds.every((id: string) => uniqueAssetPersonIds.has(id));
|
||||
}
|
||||
|
||||
return returnOutput({ passed });
|
||||
}
|
||||
|
||||
export function filterFileName() {
|
||||
const input = parseInput();
|
||||
const { data, config } = input;
|
||||
|
||||
Reference in New Issue
Block a user