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
8aa8dab2
Commit
8aa8dab2
authored
6 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
[omemo] Store last seen date of fingerprints
parent
7228a478
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
omemo/backend/liteaxolotlstore.py
+18
-2
18 additions, 2 deletions
omemo/backend/liteaxolotlstore.py
omemo/backend/state.py
+4
-0
4 additions, 0 deletions
omemo/backend/state.py
with
22 additions
and
2 deletions
omemo/backend/liteaxolotlstore.py
+
18
−
2
View file @
8aa8dab2
...
...
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with OMEMO Gajim Plugin. If not, see <http://www.gnu.org/licenses/>.
import
time
import
logging
import
sqlite3
from
collections
import
namedtuple
...
...
@@ -209,7 +209,6 @@ class LiteAxolotlStore(AxolotlStore):
END TRANSACTION;
"""
%
(
add_timestamp
))
def
loadSignedPreKey
(
self
,
signedPreKeyId
):
query
=
'
SELECT record FROM signed_prekeys WHERE prekey_id = ?
'
result
=
self
.
_con
.
execute
(
query
,
(
signedPreKeyId
,
)).
fetchone
()
...
...
@@ -499,3 +498,20 @@ class LiteAxolotlStore(AxolotlStore):
def
isUntrustedIdentity
(
self
,
recipient_id
,
identity_key
):
return
self
.
getTrustForIdentity
(
recipient_id
,
identity_key
)
not
in
(
Trust
.
TRUSTED
,
Trust
.
UNDECIDED
)
def
getIdentityLastSeen
(
self
,
recipient_id
,
identity_key
):
identity_key
=
identity_key
.
getPublicKey
().
serialize
()
query
=
'''
SELECT timestamp FROM identities
WHERE recipient_id = ? AND public_key = ?
'''
result
=
self
.
_con
.
execute
(
query
,
(
recipient_id
,
identity_key
)).
fetchone
()
return
result
.
timestamp
if
result
is
not
None
else
None
def
setIdentityLastSeen
(
self
,
recipient_id
,
identity_key
):
timestamp
=
int
(
time
.
time
())
identity_key
=
identity_key
.
getPublicKey
().
serialize
()
log
.
info
(
'
Set last seen for %s %s
'
,
recipient_id
,
timestamp
)
query
=
'''
UPDATE identities SET timestamp = ?
WHERE recipient_id = ? AND public_key = ?
'''
self
.
_con
.
execute
(
query
,
(
timestamp
,
recipient_id
,
identity_key
))
self
.
_con
.
commit
()
This diff is collapsed.
Click to expand it.
omemo/backend/state.py
+
4
−
0
View file @
8aa8dab2
...
...
@@ -235,6 +235,8 @@ class OmemoState(DeviceManager):
key
=
session_cipher
.
decryptPkmsg
(
pre_key_message
)
fingerprint
=
get_fingerprint
(
identity_key
)
self
.
_storage
.
setIdentityLastSeen
(
jid
,
identity_key
)
self
.
xmpp_con
.
set_bundle
()
self
.
add_device
(
jid
,
device
)
return
key
,
fingerprint
...
...
@@ -253,6 +255,8 @@ class OmemoState(DeviceManager):
raise
SenderNotTrusted
fingerprint
=
get_fingerprint
(
identity_key
)
self
.
_storage
.
setIdentityLastSeen
(
jid
,
identity_key
)
self
.
add_device
(
jid
,
device
)
return
key
,
fingerprint
...
...
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