mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Plugin hooks (#1452)
* Refactor session and plugin code * Add context to job tasks * Show hooks in plugins page * Refactor session management
This commit is contained in:
@@ -11,6 +11,8 @@ function main() {
|
||||
doLongTask();
|
||||
} else if (modeArg == "indef") {
|
||||
doIndefiniteTask();
|
||||
} else if (modeArg == "hook") {
|
||||
doHookTask();
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
@@ -207,4 +209,9 @@ function doIndefiniteTask() {
|
||||
}
|
||||
}
|
||||
|
||||
function doHookTask() {
|
||||
log.Info("JS Hook called!");
|
||||
log.Info(input.Args);
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -24,4 +24,35 @@ tasks:
|
||||
description: Sleeps for 100 seconds - interruptable
|
||||
defaultArgs:
|
||||
mode: long
|
||||
|
||||
hooks:
|
||||
- name: Log scene marker create/update
|
||||
description: Logs some stuff when creating/updating scene marker.
|
||||
triggeredBy:
|
||||
- SceneMarker.Create.Post
|
||||
- SceneMarker.Update.Post
|
||||
- SceneMarker.Delete.Post
|
||||
- Scene.Create.Post
|
||||
- Scene.Update.Post
|
||||
- Scene.Destroy.Post
|
||||
- Image.Create.Post
|
||||
- Image.Update.Post
|
||||
- Image.Destroy.Post
|
||||
- Gallery.Create.Post
|
||||
- Gallery.Update.Post
|
||||
- Gallery.Destroy.Post
|
||||
- Movie.Create.Post
|
||||
- Movie.Update.Post
|
||||
- Movie.Destroy.Post
|
||||
- Performer.Create.Post
|
||||
- Performer.Update.Post
|
||||
- Performer.Destroy.Post
|
||||
- Studio.Create.Post
|
||||
- Studio.Update.Post
|
||||
- Studio.Destroy.Post
|
||||
- Tag.Create.Post
|
||||
- Tag.Update.Post
|
||||
- Tag.Destroy.Post
|
||||
defaultArgs:
|
||||
mode: hook
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@ class StashInterface:
|
||||
|
||||
self.url = scheme + "://localhost:" + str(self.port) + "/graphql"
|
||||
|
||||
# TODO - cookies
|
||||
# Session cookie for authentication
|
||||
self.cookies = {
|
||||
'session': conn.get('SessionCookie').get('Value')
|
||||
}
|
||||
|
||||
def __callGraphQL(self, query, variables = None):
|
||||
json = {}
|
||||
@@ -26,7 +29,7 @@ class StashInterface:
|
||||
json['variables'] = variables
|
||||
|
||||
# handle cookies
|
||||
response = requests.post(self.url, json=json, headers=self.headers)
|
||||
response = requests.post(self.url, json=json, headers=self.headers, cookies=self.cookies)
|
||||
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
|
||||
Reference in New Issue
Block a user