respect voice state for receiving file messages

we should also check on send in the future
This commit is contained in:
Green Sky 2024-11-06 10:50:42 +01:00
parent 01c892df8c
commit 37b92f67c8
No known key found for this signature in database
2 changed files with 24 additions and 1 deletions

View File

@ -1165,6 +1165,13 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_message& e) {
return false; return false;
} }
// TODO: make perms go though contacts
// TODO: consider temporal component? not here, here is now
if (!_tcm.groupPeerCanSpeak(e.group_number, e.peer_number)) {
// peer has not the permission to speak, discard
return false; // return true?
}
uint64_t ts = Message::getTimeMS(); uint64_t ts = Message::getTimeMS();
const auto c = _tcm.getContactGroupPeer(e.group_number, e.peer_number); const auto c = _tcm.getContactGroupPeer(e.group_number, e.peer_number);

View File

@ -1,5 +1,6 @@
#include "./ngc_hs2_send.hpp" #include "./ngc_hs2_send.hpp"
#include "solanaceae/util/span.hpp"
#include <solanaceae/util/span.hpp>
#include <solanaceae/tox_contacts/tox_contact_model2.hpp> #include <solanaceae/tox_contacts/tox_contact_model2.hpp>
@ -51,10 +52,23 @@ void NGCHS2Send::handleRange(Contact3Handle c, const Events::NGCFT1_recv_request
void NGCHS2Send::handleSingleMessage(Contact3Handle c, const Events::NGCFT1_recv_request& e) { void NGCHS2Send::handleSingleMessage(Contact3Handle c, const Events::NGCFT1_recv_request& e) {
ByteSpan fid{e.file_id, e.file_id_size}; ByteSpan fid{e.file_id, e.file_id_size};
if (fid.size != 32+sizeof(uint32_t)+sizeof(uint64_t)) {
// error
return;
}
// parse // parse
// - ppk // - ppk
// TOX_GROUP_PEER_PUBLIC_KEY_SIZE (32)
ByteSpan ppk{fid.ptr, 32};
// - mid // - mid
//static_assert(sizeof(Tox_Group_Message_Id) == sizeof(uint32_t));
ByteSpan mid_bytes{fid.ptr+ppk.size, sizeof(uint32_t)};
// - ts // - ts
// uint64_t (seconds? we dont want milliseconds
ByteSpan ts_bytes{mid_bytes.ptr+mid_bytes.size, sizeof(uint64_t)};
// file content // file content
// - message type (text/textaction/file(ft1sha1)) // - message type (text/textaction/file(ft1sha1))
@ -64,6 +78,8 @@ void NGCHS2Send::handleSingleMessage(Contact3Handle c, const Events::NGCFT1_recv
// - file type // - file type
// - file id // - file id
// for queue, we need group, peer, msg_ppk, msg_mid, msg_ts
// dedupe insert into queue // dedupe insert into queue
} }