|
|
|
@ -531,6 +531,9 @@ static int db_verify_author_sig(struct DB_SYNC_INSTANCE* si, |
|
|
|
const char* json, size_t jlen, |
|
|
|
const char* json, size_t jlen, |
|
|
|
const uint8_t* sig) |
|
|
|
const uint8_t* sig) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!sig || jlen > DB_SYNC_MESSAGE_MAX || (jlen && !json)) { |
|
|
|
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "history: invalid signed body tbl=%s bytes=%zu", SI_TBL(si), jlen); return -1; |
|
|
|
|
|
|
|
} |
|
|
|
uint8_t pubkey[32]; |
|
|
|
uint8_t pubkey[32]; |
|
|
|
if (db_get_ed25519_pubkey(si->db_sync, author_node_id, pubkey) != 0) { |
|
|
|
if (db_get_ed25519_pubkey(si->db_sync, author_node_id, pubkey) != 0) { |
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_CHAT_SYNC, |
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_CHAT_SYNC, |
|
|
|
@ -638,7 +641,11 @@ static int db_record_insert_cascade(struct DB_SYNC_INSTANCE* si, |
|
|
|
int ret = db_record_insert(si, rid, rts, rauthor, rdata, rdlen, rsig, local_attrs); |
|
|
|
int ret = db_record_insert(si, rid, rts, rauthor, rdata, rdlen, rsig, local_attrs); |
|
|
|
if (ret != 0) return ret; |
|
|
|
if (ret != 0) return ret; |
|
|
|
|
|
|
|
|
|
|
|
if (si->on_insert) si->on_insert(si, rts, rdata, rdlen, rauthor, initial_sync, si->on_insert_arg); |
|
|
|
if (si->on_insert) { |
|
|
|
|
|
|
|
uint8_t message_id[32]; |
|
|
|
|
|
|
|
if (chat_message_id(si->group_id, rts, rsig, message_id) < 0) return -1; |
|
|
|
|
|
|
|
si->on_insert(si, message_id, rts, rdata, rdlen, rauthor, initial_sync, si->on_insert_arg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint8_t pbuf[4096]; uint32_t poff = 1; pbuf[0] = DB_MSG_PUSH; |
|
|
|
uint8_t pbuf[4096]; uint32_t poff = 1; pbuf[0] = DB_MSG_PUSH; |
|
|
|
memcpy(pbuf + poff, &rid, 8); poff += 8; |
|
|
|
memcpy(pbuf + poff, &rid, 8); poff += 8; |
|
|
|
|