Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gajim-plugins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
gajim
gajim-plugins
Commits
5aaa6957
Commit
5aaa6957
authored
6 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
[omemo] Add sqlite SessionRecord converter
parent
0ee9b2fa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
omemo/backend/liteaxolotlstore.py
+15
-16
15 additions, 16 deletions
omemo/backend/liteaxolotlstore.py
with
15 additions
and
16 deletions
omemo/backend/liteaxolotlstore.py
+
15
−
16
View file @
5aaa6957
...
...
@@ -42,14 +42,20 @@ log = logging.getLogger('gajim.plugin_system.omemo')
def
_convert_to_string
(
text
):
return
text
.
decode
()
def
_convert_identity_key
(
key
):
if
not
key
:
return
return
IdentityKeyExtended
(
DjbECPublicKey
(
key
[
1
:]))
def
_convert_record
(
record
):
return
SessionRecord
(
serialized
=
record
)
sqlite3
.
register_converter
(
'
jid
'
,
_convert_to_string
)
sqlite3
.
register_converter
(
'
pk
'
,
_convert_identity_key
)
sqlite3
.
register_converter
(
'
session_record
'
,
_convert_record
)
class
LiteAxolotlStore
(
AxolotlStore
):
...
...
@@ -273,12 +279,10 @@ class LiteAxolotlStore(AxolotlStore):
self
.
_con
.
commit
()
def
loadSession
(
self
,
recipientId
,
deviceId
):
query
=
'''
SELECT record
FROM sessions WHERE
recipient_id = ? AND device_id = ?
'''
query
=
'''
SELECT record
as
"
record [session_record]
"
FROM sessions WHERE
recipient_id = ? AND device_id = ?
'''
result
=
self
.
_con
.
execute
(
query
,
(
recipientId
,
deviceId
)).
fetchone
()
if
result
is
None
:
return
SessionRecord
()
return
SessionRecord
(
serialized
=
result
.
record
)
return
result
.
record
if
result
is
not
None
else
SessionRecord
()
def
getJidFromDevice
(
self
,
device_id
):
query
=
'''
SELECT recipient_id as
"
recipient_id [jid]
"
...
...
@@ -350,17 +354,10 @@ class LiteAxolotlStore(AxolotlStore):
self
.
_con
.
commit
()
def
getInactiveSessionsKeys
(
self
,
recipientId
):
query
=
'''
SELECT record FROM sessions
query
=
'''
SELECT record
as
"
record [session_record]
"
FROM sessions
WHERE active = 0 AND recipient_id = ?
'''
result
=
self
.
_con
.
execute
(
query
,
(
recipientId
,)).
fetchall
()
results
=
[]
for
row
in
result
:
public_key
=
(
SessionRecord
(
serialized
=
row
.
record
).
getSessionState
().
getRemoteIdentityKey
().
getPublicKey
())
results
.
append
(
public_key
.
serialize
())
return
results
return
[
row
.
record
.
getSessionState
().
getRemoteIdentityKey
()
for
row
in
result
]
def
loadPreKey
(
self
,
preKeyId
):
query
=
'''
SELECT record FROM prekeys WHERE prekey_id = ?
'''
...
...
@@ -465,9 +462,9 @@ class LiteAxolotlStore(AxolotlStore):
return
result
.
trust
if
result
is
not
None
else
None
def
getFingerprints
(
self
,
jid
):
query
=
'''
SELECT
_id,
recipient_id as
"
recipient_id [jid]
"
,
query
=
'''
SELECT recipient_id as
"
recipient_id [jid]
"
,
public_key as
"
public_key [pk]
"
, trust FROM identities
WHERE recipient_id =? ORDER BY trust ASC
'''
WHERE recipient_id =
? ORDER BY trust ASC
'''
return
self
.
_con
.
execute
(
query
,
(
jid
,)).
fetchall
()
def
getTrustedFingerprints
(
self
,
jid
):
...
...
@@ -530,5 +527,7 @@ class LiteAxolotlStore(AxolotlStore):
def
getUnacknowledgedCount
(
self
,
recipient_id
,
device_id
):
record
=
self
.
loadSession
(
recipient_id
,
device_id
)
if
record
.
isFresh
():
return
0
state
=
record
.
getSessionState
()
return
state
.
getSenderChainKey
().
getIndex
()
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