Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
l-n-s
gajim
Commits
da46bdda
Commit
da46bdda
authored
6 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Remove delay parsing from Gajim
Use nbxmpp's delay parsing
parent
f5fe4fd8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gajim/common/modules/chatstates.py
+1
-2
1 addition, 2 deletions
gajim/common/modules/chatstates.py
gajim/common/modules/misc.py
+0
-44
0 additions, 44 deletions
gajim/common/modules/misc.py
test/no_gui/unit/test_helpers.py
+0
-30
0 additions, 30 deletions
test/no_gui/unit/test_helpers.py
with
1 addition
and
76 deletions
gajim/common/modules/chatstates.py
+
1
−
2
View file @
da46bdda
...
...
@@ -30,7 +30,6 @@ from gi.repository import GLib
from
gajim.common
import
app
from
gajim.common.nec
import
NetworkEvent
from
gajim.common.const
import
Chatstate
as
State
from
gajim.common.modules.misc
import
parse_delay
from
gajim.common.modules.base
import
BaseModule
from
gajim.common.connection_handlers_events
import
MessageOutgoingEvent
from
gajim.common.connection_handlers_events
import
GcMessageOutgoingEvent
...
...
@@ -53,7 +52,7 @@ def ensure_enabled(func):
def
parse_chatstate
(
stanza
:
nbxmpp
.
Message
)
->
Optional
[
str
]:
if
parse_delay
(
stanza
)
is
not
None
:
if
stanza
.
getTag
(
'
delay
'
,
namespace
=
nbxmpp
.
NS_DELAY2
)
is
not
None
:
return
None
children
=
stanza
.
getChildren
()
...
...
This diff is collapsed.
Click to expand it.
gajim/common/modules/misc.py
+
0
−
44
View file @
da46bdda
...
...
@@ -19,54 +19,10 @@ import logging
import
nbxmpp
from
gajim.common
import
app
from
gajim.common.modules.date_and_time
import
parse_datetime
log
=
logging
.
getLogger
(
'
gajim.c.m.misc
'
)
# XEP-0203: Delayed Delivery
def
parse_delay
(
stanza
,
epoch
=
True
,
convert
=
'
utc
'
,
from_
=
None
,
not_from
=
None
):
'''
Returns the first valid delay timestamp that matches
:param epoch: Returns the timestamp as epoch
:param convert: Converts the timestamp to either utc or local
:param from_: Matches only delays that have the according
from attr set
:param not_from: Matches only delays that have the according
from attr not set
'''
delays
=
stanza
.
getTags
(
'
delay
'
,
namespace
=
nbxmpp
.
NS_DELAY2
)
for
delay
in
delays
:
stamp
=
delay
.
getAttr
(
'
stamp
'
)
if
stamp
is
None
:
log
.
warning
(
'
Invalid timestamp received: %s
'
,
stamp
)
log
.
warning
(
stanza
)
continue
delay_from
=
delay
.
getAttr
(
'
from
'
)
if
from_
is
not
None
:
if
delay_from
!=
from_
:
continue
if
not_from
is
not
None
:
if
delay_from
in
not_from
:
continue
timestamp
=
parse_datetime
(
stamp
,
check_utc
=
True
,
epoch
=
epoch
,
convert
=
convert
)
if
timestamp
is
None
:
log
.
warning
(
'
Invalid timestamp received: %s
'
,
stamp
)
log
.
warning
(
stanza
)
continue
return
timestamp
# XEP-0066: Out of Band Data
def
parse_oob
(
event
):
...
...
This diff is collapsed.
Click to expand it.
test/no_gui/unit/test_helpers.py
deleted
100644 → 0
+
0
−
30
View file @
f5fe4fd8
import
unittest
import
nbxmpp
from
gajim.common.modules.misc
import
parse_delay
class
TestHelpers
(
unittest
.
TestCase
):
def
test_parse_delay
(
self
):
node
=
"""
<message>
<delay xmlns=
'
urn:xmpp:delay
'
from=
'
capulet.com
'
stamp=
'
2002-09-10T23:08:25Z
'
/>
<delay xmlns=
'
urn:xmpp:delay
'
from=
'
romeo.com
'
stamp=
'
2010-09-10T23:08:25Z
'
/>
<delay xmlns=
'
urn:xmpp:delay
'
stamp=
'
2015-09-10T23:08:25Z
'
/>
</message>
"""
message
=
nbxmpp
.
Node
(
node
=
node
)
timestamp
=
parse_delay
(
message
)
self
.
assertEqual
(
timestamp
,
1031699305.0
)
timestamp
=
parse_delay
(
message
,
from_
=
'
capulet.com
'
)
self
.
assertEqual
(
timestamp
,
1031699305.0
)
timestamp
=
parse_delay
(
message
,
from_
=
'
romeo.com
'
)
self
.
assertEqual
(
timestamp
,
1284160105.0
)
timestamp
=
parse_delay
(
message
,
not_from
=
[
'
romeo.com
'
])
self
.
assertEqual
(
timestamp
,
1031699305.0
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment