Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gajim
python-nbxmpp
Commits
e4343205
Commit
e4343205
authored
Jan 22, 2022
by
Philipp Hörist
Browse files
MUC: Add MucSubject struct
parent
548e9895
Pipeline
#9115
failed with stages
in 33 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nbxmpp/modules/muc/muc.py
View file @
e4343205
...
...
@@ -25,6 +25,7 @@ from nbxmpp.protocol import DataForm
from
nbxmpp.protocol
import
DataField
from
nbxmpp.protocol
import
NodeProcessed
from
nbxmpp.protocol
import
StanzaMalformed
from
nbxmpp.structs
import
MucSubject
from
nbxmpp.structs
import
StanzaHandler
from
nbxmpp.const
import
InviteType
from
nbxmpp.const
import
MessageType
...
...
@@ -79,9 +80,13 @@ class MUC(BaseModule):
ns
=
Namespace
.
MUC_USER
,
priority
=
11
),
StanzaHandler
(
name
=
'message'
,
callback
=
self
.
_process_
groupchat_message
,
callback
=
self
.
_process_
message_before_decryption
,
typ
=
'groupchat'
,
priority
=
6
),
StanzaHandler
(
name
=
'message'
,
callback
=
self
.
_process_message_after_decryption
,
typ
=
'groupchat'
,
priority
=
16
),
StanzaHandler
(
name
=
'message'
,
callback
=
self
.
_process_mediated_invite
,
typ
=
'normal'
,
...
...
@@ -182,7 +187,7 @@ class MUC(BaseModule):
self
.
_log
.
warning
(
stanza
)
raise
NodeProcessed
def
_process_
groupchat_message
(
self
,
_client
,
stanza
,
properties
):
def
_process_
message_before_decryption
(
self
,
_client
,
stanza
,
properties
):
properties
.
from_muc
=
True
properties
.
muc_jid
=
properties
.
jid
.
new_as_bare
()
properties
.
muc_nickname
=
properties
.
jid
.
resource
...
...
@@ -203,6 +208,13 @@ class MUC(BaseModule):
if
address
is
not
None
:
properties
.
muc_ofrom
=
JID
.
from_string
(
address
.
getAttr
(
'jid'
))
def
_process_message_after_decryption
(
self
,
_client
,
stanza
,
properties
):
if
properties
.
body
is
None
and
properties
.
subject
:
properties
.
muc_subject
=
MucSubject
(
text
=
properties
.
subject
,
author
=
properties
.
muc_nickname
,
timestamp
=
properties
.
user_timestamp
)
def
_process_message
(
self
,
_client
,
stanza
,
properties
):
muc_user
=
stanza
.
getTag
(
'x'
,
namespace
=
Namespace
.
MUC_USER
)
if
muc_user
is
None
:
...
...
nbxmpp/structs.py
View file @
e4343205
...
...
@@ -130,6 +130,12 @@ class MucConfigResult(NamedTuple):
form
:
Optional
[
Any
]
=
None
class
MucSubject
(
NamedTuple
):
text
:
str
author
:
str
timestamp
:
float
class
AffiliationResult
(
NamedTuple
):
jid
:
JID
users
:
dict
[
JID
,
dict
[
str
,
str
]]
...
...
@@ -957,6 +963,7 @@ class MessageProperties:
muc_decline
=
None
muc_user
=
None
muc_ofrom
=
None
muc_subject
:
Optional
[
MucSubject
]
=
None
captcha
:
Optional
[
CaptchaData
]
=
None
voice_request
:
Optional
[
VoiceRequest
]
=
None
self_message
:
bool
=
False
...
...
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