Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Nheko Reborn
nheko
Commits
dbdaf359
Verified
Commit
dbdaf359
authored
5 years ago
by
Joe Donofry
Browse files
Options
Downloads
Patches
Plain Diff
Cache user mentions
parent
eb2f444c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
deps/CMakeLists.txt
+2
-2
2 additions, 2 deletions
deps/CMakeLists.txt
src/Cache.cpp
+55
-0
55 additions, 0 deletions
src/Cache.cpp
src/Cache.h
+12
-0
12 additions, 0 deletions
src/Cache.h
with
69 additions
and
2 deletions
deps/CMakeLists.txt
+
2
−
2
View file @
dbdaf359
...
...
@@ -46,10 +46,10 @@ set(BOOST_SHA256
set
(
MTXCLIENT_URL
https://github.com/Nheko-Reborn/mtxclient/archive/
37df82363c800b8d6b2b172a486e395e4132e061
.tar.gz
https://github.com/Nheko-Reborn/mtxclient/archive/
b56083dfa95848c39d9290efdc5544ac07030028
.tar.gz
)
set
(
MTXCLIENT_HASH
b29dd0bc836b69bd4253499519b8396a210bba43750fb66f4ffb8453510c8dd1
)
486feb1ee9ad5fe2295fa27baaa6c67c9d90cece2435eed19be2630d59552e20
)
set
(
TWEENY_URL
https://github.com/mobius3/tweeny/archive/b94ce07cfb02a0eb8ac8aaf66137dabdaea857cf.tar.gz
...
...
This diff is collapsed.
Click to expand it.
src/Cache.cpp
+
55
−
0
View file @
dbdaf359
...
...
@@ -1934,6 +1934,61 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
lmdb
::
val
(
obj
.
dump
()));
}
}
mtx
::
responses
::
Notifications
Cache
::
getTimelineMentions
(
lmdb
::
txn
&
txn
,
const
std
::
string
&
room_id
)
{
auto
db
=
getMentionsDb
(
txn
,
room_id
);
mtx
::
responses
::
Notifications
notif
;
std
::
string
event_id
,
msg
;
auto
cursor
=
lmdb
::
cursor
::
open
(
txn
,
db
);
while
(
cursor
.
get
(
event_id
,
msg
,
MDB_NEXT
))
{
auto
obj
=
json
::
parse
(
msg
);
if
(
obj
.
count
(
"event"
)
==
0
||
obj
.
count
(
"token"
)
==
0
)
continue
;
mtx
::
responses
::
Notification
notification
;
mtx
::
responses
::
from_json
(
obj
.
at
(
"notification"
),
notification
);
notif
.
notifications
.
push_back
(
notification
);
}
cursor
.
close
();
std
::
reverse
(
notif
.
notifications
.
begin
(),
notif
.
notifications
.
end
());
return
notif
;
}
void
Cache
::
saveTimelineMentions
(
lmdb
::
txn
&
txn
,
const
std
::
string
&
room_id
,
const
mtx
::
responses
::
Notifications
&
res
)
{
auto
db
=
getMentionsDb
(
txn
,
room_id
);
using
namespace
mtx
::
events
;
using
namespace
mtx
::
events
::
state
;
for
(
const
auto
&
n
:
res
.
notifications
)
{
const
auto
event_id
=
utils
::
event_id
(
n
.
event
);
// double check that we have the correct room_id...
if
(
room_id
.
compare
(
n
.
room_id
)
!=
0
)
continue
;
json
obj
=
json
::
object
();
lmdb
::
dbi_put
(
txn
,
db
,
lmdb
::
val
(
event_id
),
lmdb
::
val
(
obj
.
dump
()));
}
txn
.
commit
();
}
void
Cache
::
markSentNotification
(
const
std
::
string
&
event_id
)
...
...
This diff is collapsed.
Click to expand it.
src/Cache.h
+
12
−
0
View file @
dbdaf359
...
...
@@ -402,6 +402,13 @@ public:
//! Check if we have sent a desktop notification for the given event id.
bool
isNotificationSent
(
const
std
::
string
&
event_id
);
//! Add a notification containing a user mention to the db.
void
saveTimelineMentions
(
lmdb
::
txn
&
txn
,
const
std
::
string
&
room_id
,
const
mtx
::
responses
::
Notifications
&
res
);
//! Get timeline items that a user was mentions in
mtx
::
responses
::
Notifications
getTimelineMentions
(
lmdb
::
txn
&
txn
,
const
std
::
string
&
room_id
);
//! Remove old unused data.
void
deleteOldMessages
();
void
deleteOldData
()
noexcept
;
...
...
@@ -660,6 +667,11 @@ private:
return
lmdb
::
dbi
::
open
(
txn
,
std
::
string
(
room_id
+
"/members"
).
c_str
(),
MDB_CREATE
);
}
lmdb
::
dbi
getMentionsDb
(
lmdb
::
txn
&
txn
,
const
std
::
string
&
room_id
)
{
return
lmdb
::
dbi
::
open
(
txn
,
std
::
string
(
room_id
+
"/mentions"
).
c_str
(),
MDB_CREATE
);
}
//! Retrieves or creates the database that stores the open OLM sessions between our device
//! and the given curve25519 key which represents another device.
//!
...
...
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