mirror of
https://github.com/immich-app/immich.git
synced 2025-12-21 20:37:37 -05:00
* feat: plugins * feat: table definition * feat: type and migration * feat: add repositories * feat: validate manifest with class-validator and load manifest info to database * feat: workflow/plugin controller/service layer * feat: implement workflow logic * feat: make trigger static * feat: dynamical instantiate plugin instances * fix: access control and helper script * feat: it works * chore: simplify * refactor: refactor and use queue for workflow execution * refactor: remove unsused property in plugin-schema * build wasm in prod * feat: plugin loader in transaction * fix: docker build arm64 * generated files * shell check * fix tests * fix: waiting for migration to finish before loading plugin * remove context reassignment * feat: use mise to manage extism tools (#23760) * pr feedback * refactor: create workflow now including create filters and actions * feat: workflow medium tests * fix: broken medium test * feat: medium tests * chore: unify workflow job * sign user id with jwt * chore: query plugin with filters and action * chore: read manifest in repository * chore: load manifest from server configs * merge main * feat: endpoint documentation * pr feedback * load plugin from absolute path * refactor:handle trigger * throw error and return early * pr feedback * unify plugin services * fix: plugins code * clean up * remove triggerConfig * clean up * displayName and methodName --------- Co-authored-by: Jason Rasmussen <jason@rasm.me> Co-authored-by: bo0tzz <git@bo0tzz.me>
72 lines
1.7 KiB
TypeScript
72 lines
1.7 KiB
TypeScript
const { updateAsset, addAssetToAlbum } = Host.getFunctions();
|
|
|
|
function parseInput() {
|
|
return JSON.parse(Host.inputString());
|
|
}
|
|
|
|
function returnOutput(output: any) {
|
|
Host.outputString(JSON.stringify(output));
|
|
return 0;
|
|
}
|
|
|
|
export function filterFileName() {
|
|
const input = parseInput();
|
|
const { data, config } = input;
|
|
const { pattern, matchType = 'contains', caseSensitive = false } = config;
|
|
|
|
const fileName = data.asset.originalFileName || data.asset.fileName || '';
|
|
const searchName = caseSensitive ? fileName : fileName.toLowerCase();
|
|
const searchPattern = caseSensitive ? pattern : pattern.toLowerCase();
|
|
|
|
let passed = false;
|
|
|
|
if (matchType === 'exact') {
|
|
passed = searchName === searchPattern;
|
|
} else if (matchType === 'regex') {
|
|
const flags = caseSensitive ? '' : 'i';
|
|
const regex = new RegExp(searchPattern, flags);
|
|
passed = regex.test(fileName);
|
|
} else {
|
|
// contains
|
|
passed = searchName.includes(searchPattern);
|
|
}
|
|
|
|
return returnOutput({ passed });
|
|
}
|
|
|
|
export function actionAddToAlbum() {
|
|
const input = parseInput();
|
|
const { authToken, config, data } = input;
|
|
const { albumId } = config;
|
|
|
|
const ptr = Memory.fromString(
|
|
JSON.stringify({
|
|
authToken,
|
|
assetId: data.asset.id,
|
|
albumId: albumId,
|
|
})
|
|
);
|
|
|
|
addAssetToAlbum(ptr.offset);
|
|
ptr.free();
|
|
|
|
return returnOutput({ success: true });
|
|
}
|
|
|
|
export function actionArchive() {
|
|
const input = parseInput();
|
|
const { authToken, data } = input;
|
|
const ptr = Memory.fromString(
|
|
JSON.stringify({
|
|
authToken,
|
|
id: data.asset.id,
|
|
visibility: 'archive',
|
|
})
|
|
);
|
|
|
|
updateAsset(ptr.offset);
|
|
ptr.free();
|
|
|
|
return returnOutput({ success: true });
|
|
}
|