Prototype send to device

This commit is contained in:
timoreo 2023-12-10 19:52:00 +01:00
parent 021274fbf6
commit 8150c15e8c
Signed by: timoreo
GPG key ID: 121A72C3512BA288
2 changed files with 8 additions and 0 deletions

View file

@ -84,6 +84,7 @@ public:
std::string sendText(std::string roomId, std::string text);
std::string sendMessage(std::string roomId, json_t* content);
std::string sendEvent(std::string roomId, std::string eventType, json_t* content);
void sendEventToDevice(const std::string& eventType, json_t* devices, json_t* content);
json_t* getStateEvent(std::string roomId, std::string type, std::string stateKey);
std::string sendStateEvent(std::string roomId, std::string type, std::string stateKey, json_t* content);
std::string redactEvent(std::string roomId, std::string eventId, std::string reason = "");

View file

@ -369,6 +369,13 @@ std::string Client::sendMessage(std::string roomId, json_t* content) {
return sendEvent(roomId, "m.room.message", content);
}
void Client::sendEventToDevice(const std::string& eventType, json_t* devices, json_t* content){
std::string txid = std::to_string(time(nullptr)) + "_REQ_" + std::to_string(requestId);
std::string path = "/_matrix/client/v3/sendToDevice/" + urlencode(eventType) + "/" + urlencode(txid);
json_t* ret = doRequest("PUT", path, content);
if (ret) json_decref(ret);
}
std::string Client::sendEvent(std::string roomId, std::string eventType, json_t* content) {
roomId = resolveRoom(roomId);
std::string txid = std::to_string(time(NULL)) + "_REQ_" + std::to_string(requestId);