Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Daniel Brötzmann
python-nbxmpp
Commits
3cde9d30
Commit
3cde9d30
authored
Oct 11, 2020
by
Philipp Hörist
Browse files
Mood: Use tasks
parent
dd866a27
Changes
1
Hide whitespace changes
Inline
Side-by-side
nbxmpp/modules/mood.py
View file @
3cde9d30
...
@@ -22,6 +22,8 @@ from nbxmpp.structs import StanzaHandler
...
@@ -22,6 +22,8 @@ from nbxmpp.structs import StanzaHandler
from
nbxmpp.structs
import
MoodData
from
nbxmpp.structs
import
MoodData
from
nbxmpp.const
import
MOODS
from
nbxmpp.const
import
MOODS
from
nbxmpp.modules.base
import
BaseModule
from
nbxmpp.modules.base
import
BaseModule
from
nbxmpp.modules.util
import
finalize
from
nbxmpp.task
import
iq_request_task
class
Mood
(
BaseModule
):
class
Mood
(
BaseModule
):
...
@@ -77,7 +79,10 @@ class Mood(BaseModule):
...
@@ -77,7 +79,10 @@ class Mood(BaseModule):
properties
.
pubsub_event
=
pubsub_event
properties
.
pubsub_event
=
pubsub_event
@
iq_request_task
def
set_mood
(
self
,
data
):
def
set_mood
(
self
,
data
):
task
=
yield
item
=
Node
(
'mood'
,
{
'xmlns'
:
Namespace
.
MOOD
})
item
=
Node
(
'mood'
,
{
'xmlns'
:
Namespace
.
MOOD
})
if
data
is
not
None
and
data
.
mood
:
if
data
is
not
None
and
data
.
mood
:
item
.
addChild
(
data
.
mood
)
item
.
addChild
(
data
.
mood
)
...
@@ -85,4 +90,6 @@ class Mood(BaseModule):
...
@@ -85,4 +90,6 @@ class Mood(BaseModule):
if
data
.
text
:
if
data
.
text
:
item
.
addChild
(
'text'
,
payload
=
data
.
text
)
item
.
addChild
(
'text'
,
payload
=
data
.
text
)
self
.
publish
(
Namespace
.
MOOD
,
item
,
id_
=
'current'
)
result
=
yield
self
.
publish
(
Namespace
.
MOOD
,
item
,
id_
=
'current'
)
yield
finalize
(
task
,
result
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment