kopia lustrzana https://github.com/ryukoposting/Signal-Android
Use null when submitting empty reporting tokens.
Cleaned up a few things too, just spacing and stuff.main
rodzic
3ebafca297
commit
263fb9fc04
|
@ -3798,9 +3798,10 @@ public class MessageTable extends DatabaseTable implements MessageTypes, Recipie
|
||||||
List<ReportSpamData> data = new ArrayList<>();
|
List<ReportSpamData> data = new ArrayList<>();
|
||||||
try (Cursor cursor = db.query(TABLE_NAME, new String[] { RECIPIENT_ID, SERVER_GUID, DATE_RECEIVED }, query, args, null, null, DATE_RECEIVED + " DESC", "3")) {
|
try (Cursor cursor = db.query(TABLE_NAME, new String[] { RECIPIENT_ID, SERVER_GUID, DATE_RECEIVED }, query, args, null, null, DATE_RECEIVED + " DESC", "3")) {
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
RecipientId id = RecipientId.from(CursorUtil.requireLong(cursor, RECIPIENT_ID));
|
RecipientId id = RecipientId.from(CursorUtil.requireLong(cursor, RECIPIENT_ID));
|
||||||
String serverGuid = CursorUtil.requireString(cursor, SERVER_GUID);
|
String serverGuid = CursorUtil.requireString(cursor, SERVER_GUID);
|
||||||
long dateReceived = CursorUtil.requireLong(cursor, DATE_RECEIVED);
|
long dateReceived = CursorUtil.requireLong(cursor, DATE_RECEIVED);
|
||||||
|
|
||||||
if (!Util.isEmpty(serverGuid)) {
|
if (!Util.isEmpty(serverGuid)) {
|
||||||
data.add(new ReportSpamData(id, serverGuid, dateReceived));
|
data.add(new ReportSpamData(id, serverGuid, dateReceived));
|
||||||
}
|
}
|
||||||
|
@ -4164,9 +4165,7 @@ public class MessageTable extends DatabaseTable implements MessageTypes, Recipie
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NonNull List<MessageTable.ReportSpamData> getReportSpamMessageServerData(long threadId, long timestamp, int limit) {
|
public @NonNull List<MessageTable.ReportSpamData> getReportSpamMessageServerData(long threadId, long timestamp, int limit) {
|
||||||
return SignalDatabase
|
return getReportSpamMessageServerGuids(threadId, timestamp)
|
||||||
.messages()
|
|
||||||
.getReportSpamMessageServerGuids(threadId, timestamp)
|
|
||||||
.stream()
|
.stream()
|
||||||
.sorted((l, r) -> -Long.compare(l.getDateReceived(), r.getDateReceived()))
|
.sorted((l, r) -> -Long.compare(l.getDateReceived(), r.getDateReceived()))
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
|
|
@ -75,13 +75,14 @@ public class ReportSpamJob extends BaseJob {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
List<ReportSpamData> reportSpamData = SignalDatabase.messages().getReportSpamMessageServerData(threadId, timestamp, MAX_MESSAGE_COUNT);
|
List<ReportSpamData> reportSpamData = SignalDatabase.messages().getReportSpamMessageServerData(threadId, timestamp, MAX_MESSAGE_COUNT);
|
||||||
SignalServiceAccountManager signalServiceAccountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
SignalServiceAccountManager signalServiceAccountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||||
for (ReportSpamData data : reportSpamData) {
|
|
||||||
final RecipientId recipientId = data.getRecipientId();
|
|
||||||
|
|
||||||
Optional<ServiceId> serviceId = Recipient.resolved(recipientId).getServiceId();
|
for (ReportSpamData data : reportSpamData) {
|
||||||
|
RecipientId recipientId = data.getRecipientId();
|
||||||
|
Recipient recipient = Recipient.resolved(recipientId);
|
||||||
|
Optional<ServiceId> serviceId = recipient.getServiceId();
|
||||||
|
|
||||||
if (serviceId.isPresent() && !serviceId.get().isUnknown()) {
|
if (serviceId.isPresent() && !serviceId.get().isUnknown()) {
|
||||||
String reportingTokenEncoded = "";
|
String reportingTokenEncoded = null;
|
||||||
|
|
||||||
byte[] reportingTokenBytes = SignalDatabase.recipients().getReportingToken(recipientId);
|
byte[] reportingTokenBytes = SignalDatabase.recipients().getReportingToken(recipientId);
|
||||||
if (reportingTokenBytes != null) {
|
if (reportingTokenBytes != null) {
|
||||||
|
|
|
@ -2,4 +2,4 @@ package org.whispersystems.signalservice.internal.push
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
|
||||||
data class SpamTokenMessage(@JsonProperty val token: String)
|
data class SpamTokenMessage(@JsonProperty val token: String?)
|
||||||
|
|
Ładowanie…
Reference in New Issue