0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-28 19:58:53 +02:00

modules/client/presence: Check for redundant status updates from client.

This commit is contained in:
Jason Volk 2018-04-23 17:50:47 -07:00
parent 7889d116f0
commit d534ee8afa

View file

@ -314,8 +314,38 @@ put__presence_status(client &client,
trunc(unquote(request["status_msg"]), 390)
};
const m::user user{request.user_id};
m::presence::set(user, presence, status_msg);
const m::user user
{
request.user_id
};
// note: Riot hits this endpoint with redundant updates every single time
// the user waves their mouse over the browser window. Right now we throw
// NOT_MODIFIED and do nothing because each presence update writes a msg
// to the user's room. In the future we can put a conf/hook here to do
// more w/ this data though.
m::presence::get(std::nothrow, user, [&presence, &status_msg]
(const json::object &object)
{
if(unquote(object.get("presence")) != presence)
return;
if(unquote(object.get("status_msg")) != status_msg)
return;
throw m::error
{
http::NOT_MODIFIED, "M_NOT_MODIFIED",
"Presence state or status has not changed"
};
});
const auto eid
{
m::presence::set(user, presence, status_msg)
};
return resource::response
{
client, http::OK