0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

modules/m_user: Additional derived tools for linear highlight counting.

This commit is contained in:
Jason Volk 2018-09-14 05:32:37 -07:00
parent 5daa57d447
commit b1cd9edcd2

View file

@ -85,3 +85,37 @@ highlighted_count__between(const user &user,
return ret;
}
extern "C" size_t
highlighted_count__since(const user &user,
const room &room,
const event::idx &current)
{
event::id::buf last_read_buf;
const event::id last_read
{
receipt::read(last_read_buf, room, user)
};
if(!last_read)
return 0;
const auto &a
{
index(last_read)
};
return highlighted_count__between(user, room, a, current);
}
extern "C" size_t
highlighted_count(const user &user,
const room &room)
{
const auto &current
{
head_idx(room)
};
return highlighted_count__since(user, room, current);
}