Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Sebastiaan Lokhorst
gajim
Commits
be2f3053
Commit
be2f3053
authored
Oct 26, 2019
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor blocking non-roster messages
parent
d7af6eb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
5 deletions
+25
-5
gajim/common/modules/message.py
gajim/common/modules/message.py
+25
-0
gajim/session.py
gajim/session.py
+0
-5
No files found.
gajim/common/modules/message.py
View file @
be2f3053
...
...
@@ -36,6 +36,9 @@ class Message(BaseModule):
BaseModule
.
__init__
(
self
,
con
)
self
.
handlers
=
[
StanzaHandler
(
name
=
'message'
,
callback
=
self
.
_check_if_unknown_contact
,
priority
=
41
),
StanzaHandler
(
name
=
'message'
,
callback
=
self
.
_message_received
,
priority
=
50
),
...
...
@@ -49,6 +52,28 @@ class Message(BaseModule):
self
.
_message_namespaces
=
set
([
nbxmpp
.
NS_ROSTERX
,
nbxmpp
.
NS_IBB
])
def
_check_if_unknown_contact
(
self
,
_con
,
stanza
,
properties
):
if
(
properties
.
type
.
is_groupchat
or
properties
.
is_muc_pm
or
properties
.
is_self_message
or
properties
.
is_mam_message
):
return
if
self
.
_con
.
get_own_jid
().
getDomain
()
==
str
(
properties
.
jid
):
# Server message
return
if
not
app
.
config
.
get_per
(
'accounts'
,
self
.
_account
,
'ignore_unknown_contacts'
):
return
jid
=
properties
.
jid
.
getBare
()
if
self
.
_con
.
get_module
(
'Roster'
).
get_item
(
jid
)
is
None
:
self
.
_log
.
warning
(
'Ignore message from unknown contact: %s'
,
jid
)
self
.
_log
.
warning
(
stanza
)
raise
nbxmpp
.
NodeProcessed
def
_message_received
(
self
,
_con
,
stanza
,
properties
):
if
(
properties
.
is_mam_message
or
properties
.
is_pubsub
or
...
...
gajim/session.py
View file @
be2f3053
...
...
@@ -147,11 +147,6 @@ class ChatControlSession:
if
not
obj
.
msgtxt
:
# empty message text
return
True
if
app
.
config
.
get_per
(
'accounts'
,
self
.
conn
.
name
,
'ignore_unknown_contacts'
)
and
not
app
.
contacts
.
get_contacts
(
self
.
conn
.
name
,
obj
.
jid
)
and
not
pm
:
return
True
if
not
self
.
control
:
ctrl
=
app
.
interface
.
msg_win_mgr
.
search_control
(
obj
.
jid
,
obj
.
conn
.
name
,
obj
.
resource
)
...
...
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