1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(corefile): include file id in map when sending empty avatar

This commit is contained in:
Anthony Bilinski 2019-05-09 02:26:17 -07:00
parent cef773c4f6
commit b1eefc3f23
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -91,19 +91,22 @@ void CoreFile::sendAvatarFile(uint32_t friendId, const QByteArray& data)
{
QMutexLocker{coreLoopLock};
if (data.isEmpty()) {
tox_file_send(tox, friendId, TOX_FILE_KIND_AVATAR, 0, nullptr, nullptr, 0, nullptr);
return;
uint64_t filesize = 0;
uint8_t *file_id = nullptr;
uint8_t *file_name = nullptr;
size_t nameLength = 0;
if (!data.isEmpty()) {
static_assert(TOX_HASH_LENGTH <= TOX_FILE_ID_LENGTH, "TOX_HASH_LENGTH > TOX_FILE_ID_LENGTH!");
uint8_t avatarHash[TOX_HASH_LENGTH];
tox_hash(avatarHash, (uint8_t*)data.data(), data.size());
filesize = data.size();
file_id = avatarHash;
file_name = avatarHash;
nameLength = TOX_HASH_LENGTH;
}
static_assert(TOX_HASH_LENGTH <= TOX_FILE_ID_LENGTH, "TOX_HASH_LENGTH > TOX_FILE_ID_LENGTH!");
uint8_t avatarHash[TOX_HASH_LENGTH];
tox_hash(avatarHash, (uint8_t*)data.data(), data.size());
uint64_t filesize = data.size();
Tox_Err_File_Send error;
uint32_t fileNum = tox_file_send(tox, friendId, TOX_FILE_KIND_AVATAR, filesize,
avatarHash, avatarHash, TOX_HASH_LENGTH, &error);
const uint32_t fileNum = tox_file_send(tox, friendId, TOX_FILE_KIND_AVATAR, filesize,
file_id, file_name, nameLength, &error);
switch (error) {
case TOX_ERR_FILE_SEND_OK: