summaryrefslogtreecommitdiffstats
path: root/module/api/UserInteractionApi.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/api/UserInteractionApi.py')
-rw-r--r--module/api/UserInteractionApi.py32
1 files changed, 14 insertions, 18 deletions
diff --git a/module/api/UserInteractionApi.py b/module/api/UserInteractionApi.py
index ded305c30..b95b7c468 100644
--- a/module/api/UserInteractionApi.py
+++ b/module/api/UserInteractionApi.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from module.Api import Api, RequirePerm, Permission, InteractionTask
+from module.Api import Api, RequirePerm, Permission, Interaction
from ApiComponent import ApiComponent
@@ -15,40 +15,36 @@ class UserInteractionApi(ApiComponent):
:param mode: binary or'ed output type
:return: boolean
"""
- return self.core.interactionManager.isTaskWaiting(mode)
+ return self.core.interactionManager.isTaskWaiting(self.primaryUID, mode)
@RequirePerm(Permission.Interaction)
- def getInteractionTask(self, mode):
+ def getInteractionTasks(self, mode):
"""Retrieve task for specific mode.
- :param mode: binary or'ed output type
- :return: :class:`InteractionTask`
+ :param mode: binary or'ed interaction types which should be retrieved
+ :rtype list of :class:`InteractionTask`
"""
- task = self.core.interactionManager.getTask(mode)
- return InteractionTask(-1) if not task else task
+ tasks = self.core.interactionManager.getTasks(self.primaryUID, mode)
+ # retrieved tasks count as seen
+ for t in tasks:
+ t.seen = True
+ if t.type == Interaction.Notification:
+ t.setWaiting(self.core.interactionManager.CLIENT_THRESHOLD)
+ return tasks
@RequirePerm(Permission.Interaction)
def setInteractionResult(self, iid, result):
"""Set Result for a interaction task. It will be immediately removed from task queue afterwards
:param iid: interaction id
- :param result: result as string
+ :param result: result as json string
"""
task = self.core.interactionManager.getTaskByID(iid)
- if task:
+ if task and self.primaryUID == task.owner:
task.setResult(result)
@RequirePerm(Permission.Interaction)
- def getNotifications(self):
- """List of all available notifcations. They stay in queue for some time, client should\
- save which notifications it already has seen.
-
- :return: list of :class:`InteractionTask`
- """
- return self.core.interactionManager.getNotifications()
-
- @RequirePerm(Permission.Interaction)
def getAddonHandler(self):
pass