Commit 8e99facd authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Activity: Use tasks

parent 0a3564f7
......@@ -22,6 +22,8 @@ from nbxmpp.structs import StanzaHandler
from nbxmpp.structs import ActivityData
from nbxmpp.const import ACTIVITIES
from nbxmpp.modules.base import BaseModule
from nbxmpp.modules.util import finalize
from nbxmpp.task import iq_request_task
class Activity(BaseModule):
......@@ -87,7 +89,10 @@ class Activity(BaseModule):
return sub.getName()
return None
@iq_request_task
def set_activity(self, data):
task = yield
item = Node('activity', {'xmlns': Namespace.ACTIVITY})
if data is not None and data.activity:
activity_node = item.addChild(data.activity)
......@@ -96,4 +101,6 @@ class Activity(BaseModule):
if data.text:
item.addChild('text', payload=data.text)
self.publish(Namespace.ACTIVITY, item, id_='current')
result = yield self.publish(Namespace.ACTIVITY, item, id_='current')
yield finalize(task, result)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment