add sending typing notifs

This commit is contained in:
Sorunome 2019-10-26 18:25:02 +02:00
parent 0d18f93410
commit b99305ca82
No known key found for this signature in database
GPG key ID: 63E31F7B5993A9C4
2 changed files with 14 additions and 0 deletions

View file

@ -84,6 +84,7 @@ public:
std::string getRoomAvatar(std::string roomId);
std::string getCanonicalAlias(std::string roomId);
void sendReadReceipt(std::string roomId, std::string eventId);
void setTyping(std::string roomId, bool typing, u32 timeout = 30000);
std::string sendEmote(std::string roomId, std::string text);
std::string sendNotice(std::string roomId, std::string text);
std::string sendText(std::string roomId, std::string text);

View file

@ -281,6 +281,7 @@ std::string Client::getCanonicalAlias(std::string roomId) {
}
void Client::sendReadReceipt(std::string roomId, std::string eventId) {
roomId = resolveRoom(roomId);
std::string path = "/_matrix/client/r0/rooms/" + urlencode(roomId) + "/receipt/m.read/" + urlencode(eventId);
json_t* ret = doRequest("POST", path);
if (ret) {
@ -288,6 +289,18 @@ void Client::sendReadReceipt(std::string roomId, std::string eventId) {
}
}
void Client::setTyping(std::string roomId, bool typing, u32 timeout) {
roomId = resolveRoom(roomId);
std::string userId = getUserId();
std::string path = "/_matrix/client/r0/rooms/" + urlencode(roomId) + "/typing/" + urlencode(userId);
json_t* request = json_object();
json_object_set_new(request, "typing", json_boolean(typing));
json_object_set_new(request, "timeout", json_integer(timeout));
json_t* ret = doRequest("PUT", path, request);
json_decref(request);
json_decref(ret);
}
std::string Client::sendEmote(std::string roomId, std::string text) {
json_t* request = json_object();
json_object_set_new(request, "msgtype", json_string("m.emote"));