Skip to content

Commit

Permalink
Handle messagerequesttypes BLOCK and UNBLOCK (importFromDesktop). Rec…
Browse files Browse the repository at this point in the history
…ognize north american international call prefix
  • Loading branch information
bepaald committed Feb 2, 2025
1 parent 6303f36 commit 2378c15
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion autoversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
#ifndef VERSION_H_
#define VERSION_H_

#define VERSIONDATE "20250131.160052"
#define VERSIONDATE "20250202.120222"

#endif
20 changes: 11 additions & 9 deletions signalbackup/importfromdesktop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1140,10 +1140,12 @@ bool SignalBackup::importFromDesktop(std::unique_ptr<DesktopDatabase> const &dtd
uint64_t response_type = 0;
if (request_response == "ACCEPT")
response_type = Types::SPECIAL_TYPE_MESSAGE_REQUEST_ACCEPTED;
else if (request_response == "BLOCK")
continue; // This type does not leave any actual message in the Android database.
else if (request_response == "UNBLOCK")
response_type = Types::SPECIAL_TYPE_MESSAGE_REQUEST_ACCEPTED; // this only actually shows up in Android when done on Desktop, when unblocked on android, it shows no message.
//else if (request_response == "DELETE")
// ;
//else if (request_response == "BLOCK")
// ;
//else if (request_response == "BLOCK_AND_DELETE")
// ;
//else if (request_response == "SPAM")
Expand All @@ -1164,14 +1166,14 @@ bool SignalBackup::importFromDesktop(std::unique_ptr<DesktopDatabase> const &dtd
continue;
}

long long message_request_accepted_type = response_type | Types::SECURE_MESSAGE_BIT | Types::PUSH_MESSAGE_BIT | (outgoing ? Types::BASE_SENDING_TYPE : Types::BASE_INBOX_TYPE);
long long message_request_response_type = response_type | Types::SECURE_MESSAGE_BIT | Types::PUSH_MESSAGE_BIT | (outgoing ? Types::BASE_SENDING_TYPE : Types::BASE_INBOX_TYPE);

if (d_database.containsTable("sms"))
{
if (!insertRow("sms", {{"thread_id", ttid},
{"date_sent", results_all_messages_from_conversation.value(j, "sent_at")},
{d_sms_date_received, results_all_messages_from_conversation.value(j, "sent_at")},
{"type", message_request_accepted_type},
{"type", message_request_response_type},
{"read", 1}, // hardcoded to 1 in Signal Android (for profile-change)
{d_sms_recipient_id, address}}))
{
Expand All @@ -1187,7 +1189,7 @@ bool SignalBackup::importFromDesktop(std::unique_ptr<DesktopDatabase> const &dtd
if (!insertRow(d_mms_table, {{"thread_id", ttid},
{d_mms_date_sent, results_all_messages_from_conversation.value(j, "sent_at")},
{"date_received", results_all_messages_from_conversation.value(j, "sent_at")},
{d_mms_type, message_request_accepted_type},
{d_mms_type, message_request_response_type},
{d_mms_recipient_id, address},
{d_mms_recipient_device_id, 1}, // not sure what this is but at least for profile-change
{"read", 1}})) // it is hardcoded to 1 in Signal Android (as is 'read')
Expand All @@ -1203,7 +1205,7 @@ bool SignalBackup::importFromDesktop(std::unique_ptr<DesktopDatabase> const &dtd
// newer tables have a unique constraint on date_sent/thread_id/from_recipient_id, so
// we try to get the first free date_sent
long long int originaldate = results_all_messages_from_conversation.getValueAs<long long int>(j, "sent_at");
long long int freedate = getFreeDateForMessage(originaldate, ttid, Types::isOutgoing(message_request_accepted_type) ? d_selfid : address);
long long int freedate = getFreeDateForMessage(originaldate, ttid, Types::isOutgoing(message_request_response_type) ? d_selfid : address);
if (freedate == -1)
{
if (d_verbose) [[unlikely]] Logger::message_end();
Expand All @@ -1216,9 +1218,9 @@ bool SignalBackup::importFromDesktop(std::unique_ptr<DesktopDatabase> const &dtd
if (!insertRow(d_mms_table, {{"thread_id", ttid},
{d_mms_date_sent, freedate},
{"date_received", freedate},
{d_mms_type, message_request_accepted_type},
{d_mms_recipient_id, Types::isOutgoing(message_request_accepted_type) ? d_selfid : address},
{"to_recipient_id", Types::isOutgoing(message_request_accepted_type) ? address : d_selfid},
{d_mms_type, message_request_response_type},
{d_mms_recipient_id, Types::isOutgoing(message_request_response_type) ? d_selfid : address},
{"to_recipient_id", Types::isOutgoing(message_request_response_type) ? address : d_selfid},
{d_mms_recipient_device_id, 1}, // not sure what this is but at least for profile-change
{"read", 1}})) // it is hardcoded to 1 in Signal Android (as is 'read')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ inline std::string SignalPlaintextBackupDatabase::normalizePhoneNumber(std::stri
return in;

if (STRING_STARTS_WITH(result, "00"))
result = "+" + result.substr(2);
result = "+" + result.substr(STRLEN("00"));
else if (STRING_STARTS_WITH(result, "011"))
result = "+" + result.substr(STRLEN("011"));

if (result[0] != '+' && !d_countrycode.empty())
result = d_countrycode + (result[0] == '0' ? result.substr(1) : result);
Expand Down

0 comments on commit 2378c15

Please sign in to comment.