diff --git a/core/execution/operation/__pycache__/operation.cpython-314.pyc b/core/execution/operation/__pycache__/operation.cpython-314.pyc index f08d160..b2d9526 100644 Binary files a/core/execution/operation/__pycache__/operation.cpython-314.pyc and b/core/execution/operation/__pycache__/operation.cpython-314.pyc differ diff --git a/core/execution/operation/operation.py b/core/execution/operation/operation.py index 5537234..ba99a29 100644 --- a/core/execution/operation/operation.py +++ b/core/execution/operation/operation.py @@ -19,9 +19,16 @@ def buildOperation(definition): if skipStep(definition, action, outputs): continue + if hasattr(action, "recursive"): + for item in outputs[action.recursive["source"]]: + #target = outputs[action.recursive["source"]["target"] + outputs, response = buildAction(action, outputs) + #print(outputs["message"]) + return outputs outputs, response = buildAction(action, outputs) responses.append(response) #except Exception as error: #outputs = manageFailure(error, action, outputs) + #print(outputs["message"]) return outputs diff --git a/core/runtime/__pycache__/runtimecontract.cpython-314.pyc b/core/runtime/__pycache__/runtimecontract.cpython-314.pyc index 0a08fb6..d682e14 100644 Binary files a/core/runtime/__pycache__/runtimecontract.cpython-314.pyc and b/core/runtime/__pycache__/runtimecontract.cpython-314.pyc differ diff --git a/core/runtime/__pycache__/select.cpython-314.pyc b/core/runtime/__pycache__/select.cpython-314.pyc index 8b3120b..988ac4d 100644 Binary files a/core/runtime/__pycache__/select.cpython-314.pyc and b/core/runtime/__pycache__/select.cpython-314.pyc differ diff --git a/core/runtime/runtimecontract.py b/core/runtime/runtimecontract.py index 57e43e4..3958755 100644 --- a/core/runtime/runtimecontract.py +++ b/core/runtime/runtimecontract.py @@ -1,5 +1,5 @@ from core.runtime import buildSelect, buildSelect2, buildOutput, buildSave, buildLog - +from core.runtime.select import buildSelect3 #select_data = {} def buildRuntimeAttr(action, outputs, response): @@ -15,7 +15,7 @@ def buildRuntimeAttr(action, outputs, response): outputs = buildOutput(response, action, outputs)#, select_data) if hasattr(action, "select"): - select_data, action, outputs = buildSelect2(action, outputs) + select_data, action, outputs = buildSelect3(action, outputs) #print("AFTER buildOutput:", type(outputs)) #print("DEBUG buildSave") #print("outputs type:", type(outputs)) diff --git a/core/runtime/select.py b/core/runtime/select.py index 2f5e32d..10352bc 100644 --- a/core/runtime/select.py +++ b/core/runtime/select.py @@ -18,6 +18,7 @@ def buildSelect(response, action, outputs): return selection, action, outputs + def buildSelect2(action, outputs): #print(outputs) select_data = [] @@ -25,10 +26,29 @@ def buildSelect2(action, outputs): selectmethod = action.select["selectmethod"] targetkey = action.select["key"] targetvalue = action.select["value"] + + if isinstance(targetvalue, dict): + for resolvekey, resolveval in targetvalue.items(): + print(resolvekey) + print(resolveval) + #outputtarget = outputs[resolvekey] + #for thing in resolveval: + outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]] + print (outputtarget) + targetvalue = outputtarget #for item in target: for item in target: #print (item) for key, value in item.items(): + #if isinstance(targetvalue, dict): + #for resolvekey, resolveval in targetvalue.items(): + #print(resolvekey) + #print(resolveval) + #outputtarget = outputs[resolvekey] + #for thing in resolveval: + #outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]] + #print (outputtarget) + #outputtarget = targetvalue if selectmethod == "exclude": if targetkey == key and item[key] != targetvalue: select_data.append(item) @@ -37,9 +57,76 @@ def buildSelect2(action, outputs): if targetkey == key and item[key] == targetvalue: select_data.append(item) #print(item) - print(select_data) + outputs[action.select["source"]] = select_data + #print(outputs) return select_data, action, outputs #for item in outputs[output_name]: #for key, value in action.select.include.items(): #if key in item and item[key] == value: #select_data.append(item) + +def buildSelect3(action, outputs): + #print(outputs) + select_data = [] + target = outputs[action.select["source"]] + #selectmethod = action.select["selectmethod"] + includekey = action.select["include"]["key"] + includevalue = action.select["include"]["value"] + excludekey = action.select["exclude"]["key"] + excludevalue = action.select["exclude"]["value"] + #if isinstance(targetvalue, dict): + #for resolvekey, resolveval in targetvalue.items(): + #print(resolvekey) + #print(resolveval) + #outputtarget = outputs[resolvekey] + #for thing in resolveval: + #outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]] + #print (outputtarget) + #targetvalue = outputtarget + #for item in target: + #include_match = True + #exclude_match = True + + for item in target: + include_match = True + exclude_match = True + + if includekey: + include_match = item[includekey] == includevalue + + if excludekey: + exclude_match = item[excludekey] != excludevalue + + if include_match and exclude_match: + select_data.append(item) + #print (item) + #for key, value in item.items(): + #if isinstance(targetvalue, dict): + #for resolvekey, resolveval in targetvalue.items(): + #print(resolvekey) + #print(resolveval) + #outputtarget = outputs[resolvekey] + #for thing in resolveval: + #outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]] + #print (outputtarget) + #outputtarget = targetvalue + #if selectmethod == "exclude": + #if item[excludekey] != excludevalue:# and item[includekey] == includevalue: + #if includekey == key and item[key] == includevalue: + #if item[excludekey] == excludevalue: + #continue + #select_data.append(item) + #if item[includekey] == includevalue: + #if includekey == key and item[key] == includevalue: + #continue + #select_data.append(item) + #if excludekey == key and item[key] != excludevalue: + #select_data.append(item) + #print(item) + #if selectmethod == "include": + #if excludekey == key and item[key] == excludevalue: + #select_data.append(item) + #print(item) + outputs[action.select["source"]] = select_data + print(select_data) + return select_data, action, outputs diff --git a/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc b/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc index d06a256..2f69930 100644 Binary files a/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/pullmessagelist.cpython-314.pyc b/plugins/rmass/actions/__pycache__/pullmessagelist.cpython-314.pyc index 289ddf3..2097e39 100644 Binary files a/plugins/rmass/actions/__pycache__/pullmessagelist.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/pullmessagelist.cpython-314.pyc differ diff --git a/plugins/rmass/actions/getmessage.py b/plugins/rmass/actions/getmessage.py index b13a967..a467e34 100644 --- a/plugins/rmass/actions/getmessage.py +++ b/plugins/rmass/actions/getmessage.py @@ -1,5 +1,7 @@ import os +#getoutputs = {"emails": [0, "id"]} + name = "Get message" kind = "action" @@ -8,29 +10,8 @@ kind = "action" showstatus = True -#skipstep = { -# "checkavailable": "validTo >= 3600" -#} - -#availabletime = int(os.environ.get("AVAILABLE_DURATION",3)) - -#duration = availabletime - 1 - -#keys = [ -# { -# "keytitle": "option", -# "keyvalue": 1, -# }, -# { -# "keytitle": "duration", -# "keyvalue": duration, -# }, -#] - method = "GET" -#messageid = 49971192 - #path = f"https://rentmasseur.com/api/v1/mailbox/{messageid}" #path = [ # "https://rentmasseur.com/api/v1/mailbox/", @@ -40,7 +21,7 @@ method = "GET" path = [ "https://rentmasseur.com/api/v1/mailbox/", { - "output": "messageid", + "output": "emails", "keys": [0, "id"] } ] @@ -54,10 +35,36 @@ headers = { }, } -outputs = { - "conversation": "messages" +recursive = { + "source": "emails", + "target": "id" } + +outputs = { + "message": "messages" +} + +#select = { +# "source": "message", +# "selectmethod": "include", + #"key": "id", +# "key": "seen", + #"value": {"emails": [0, "id"]}, +# "value": "false", +#} + +select = { + "source": "message", + "include": { + "key": "seen", + "value": False, + }, + "exclude": { + "key": "senderId", + "value": 238302, + } +} #prints = { # "message": "messages" #} diff --git a/plugins/rmass/actions/pullmessagelist.py b/plugins/rmass/actions/pullmessagelist.py index ced788b..eb5a888 100644 --- a/plugins/rmass/actions/pullmessagelist.py +++ b/plugins/rmass/actions/pullmessagelist.py @@ -29,6 +29,16 @@ method = "GET" #path = "https://rentmasseur.com/api/v1/mailbox?page=1&folder=1&sort=1" path = "https://rentmasseur.com/api/v1/mailbox" + + +#path = [ +# "https://rentmasseur.com/api/v1/mailbox/", +# { +# "output": "emails", +# "keys": [0, "id"] +# } +#] + headers = { "Authorization": { "output": "access_token", @@ -36,11 +46,23 @@ headers = { }, } +#select = { +# "source": "emails", +# "selectmethod": "exclude", +# "key": "unread", +# "value": 0, +#} + select = { "source": "emails", - "selectmethod": "exclude", - "key": "unread", - "value": 0, + "include": { + "key": {}, + "value": {}, + }, + "exclude": { + "key": "unread", + "value": 0, + } } outputs = { diff --git a/plugins/rmass/operations/__pycache__/pullmessagelist.cpython-314.pyc b/plugins/rmass/operations/__pycache__/pullmessagelist.cpython-314.pyc index 83b2248..a6a5cca 100644 Binary files a/plugins/rmass/operations/__pycache__/pullmessagelist.cpython-314.pyc and b/plugins/rmass/operations/__pycache__/pullmessagelist.cpython-314.pyc differ diff --git a/plugins/rmass/operations/pullmessagelist.py b/plugins/rmass/operations/pullmessagelist.py index 2b32993..c0a98e5 100644 --- a/plugins/rmass/operations/pullmessagelist.py +++ b/plugins/rmass/operations/pullmessagelist.py @@ -7,7 +7,7 @@ kind = "operation" actions = [ refresh_tokens, pullmessagelist, - #getmessage, + getmessage, #setavailable, ] diff --git a/tokens.json b/tokens.json index c6b3d6b..e4c8335 100644 --- a/tokens.json +++ b/tokens.json @@ -1 +1 @@ -{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTE4MTU5NzksIm5iZiI6MTc5MTgxNTc5OSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTgxNTg1OX0.oxYvEJrX9lQRiHtaOndLLv8bZGo1AVboC6xjKljnrHmXSJe52-urHrQsTyc1XlJV08a5z_1ctYR8yGmYejwjeQ", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ0MDc4NTksIm5iZiI6MTc5MTgxNTc5OSwianRpIjoiK25FQmd1VGxlN1g2N1V3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