mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
Make group chats a bit more future proof
This commit is contained in:
parent
717a28a446
commit
eb9537f1c1
@ -406,9 +406,9 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
if (lokiLongPoller != null) return;
|
if (lokiLongPoller != null) return;
|
||||||
String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this);
|
String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this);
|
||||||
if (userHexEncodedPublicKey == null) return;
|
if (userHexEncodedPublicKey == null) return;
|
||||||
LokiAPIDatabase database = DatabaseFactory.getLokiAPIDatabase(this);
|
LokiAPIDatabase lokiAPIDatabase = DatabaseFactory.getLokiAPIDatabase(this);
|
||||||
Context context = this;
|
Context context = this;
|
||||||
lokiLongPoller = new LokiLongPoller(userHexEncodedPublicKey, database, new Function1<List<SignalServiceProtos.Envelope>, Unit>() {
|
lokiLongPoller = new LokiLongPoller(userHexEncodedPublicKey, lokiAPIDatabase, new Function1<List<SignalServiceProtos.Envelope>, Unit>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Unit invoke(List<SignalServiceProtos.Envelope> protos) {
|
public Unit invoke(List<SignalServiceProtos.Envelope> protos) {
|
||||||
@ -430,7 +430,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
lokiGroupChatPoller = new LokiGroupChatPoller(this, LokiGroupChatAPI.getPublicChatID());
|
lokiGroupChatPoller = new LokiGroupChatPoller(this, LokiGroupChatAPI.getPublicChatID());
|
||||||
boolean isPublicChatSetUp = TextSecurePreferences.isPublicChatSetUp(this);
|
boolean isPublicChatSetUp = TextSecurePreferences.isPublicChatSetUp(this);
|
||||||
if (isPublicChatSetUp) return;
|
if (isPublicChatSetUp) return;
|
||||||
String id = "loki-group-chat-" + LokiGroupChatAPI.getPublicChatID();
|
String id = LokiGroupChatAPI.getServerURL() + "." + LokiGroupChatAPI.getPublicChatID();
|
||||||
GroupManager.createGroup(id, this, new HashSet<>(), null, "Loki Public Chat", false);
|
GroupManager.createGroup(id, this, new HashSet<>(), null, "Loki Public Chat", false);
|
||||||
TextSecurePreferences.markPublicChatSetUp(this);
|
TextSecurePreferences.markPublicChatSetUp(this);
|
||||||
}
|
}
|
||||||
|
@ -2872,7 +2872,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
try {
|
try {
|
||||||
messageSender.sendMessage(0, address, Optional.absent(), message); // The message ID doesn't matter
|
messageSender.sendMessage(0, address, Optional.absent(), message); // The message ID doesn't matter
|
||||||
DatabaseFactory.getLokiThreadDatabase(context).setFriendRequestStatus(this.threadId, LokiThreadFriendRequestStatus.FRIENDS);
|
DatabaseFactory.getLokiThreadDatabase(context).setFriendRequestStatus(this.threadId, LokiThreadFriendRequestStatus.FRIENDS);
|
||||||
DatabaseFactory.getLokiMessageFriendRequestDatabase(context).setFriendRequestStatus(friendRequest.id, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED);
|
DatabaseFactory.getLokiMessageDatabase(context).setFriendRequestStatus(friendRequest.id, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d("Loki", "Failed to send background message to: " + contactID + ".");
|
Log.d("Loki", "Failed to send background message to: " + contactID + ".");
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil;
|
|||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.loki.FriendRequestView;
|
import org.thoughtcrime.securesms.loki.FriendRequestView;
|
||||||
import org.thoughtcrime.securesms.loki.FriendRequestViewDelegate;
|
import org.thoughtcrime.securesms.loki.FriendRequestViewDelegate;
|
||||||
import org.thoughtcrime.securesms.loki.LokiMessageFriendRequestDatabase;
|
import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||||
import org.thoughtcrime.securesms.mms.ImageSlide;
|
import org.thoughtcrime.securesms.mms.ImageSlide;
|
||||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||||
@ -979,8 +979,8 @@ public class ConversationItem extends LinearLayout
|
|||||||
int spacingBottom = spacingTop;
|
int spacingBottom = spacingTop;
|
||||||
|
|
||||||
boolean isOutgoingStack = current.isOutgoing() && previous.orNull() != null && previous.get().isOutgoing();
|
boolean isOutgoingStack = current.isOutgoing() && previous.orNull() != null && previous.get().isOutgoing();
|
||||||
LokiMessageFriendRequestDatabase friendRequestDatabase = DatabaseFactory.getLokiMessageFriendRequestDatabase(context);
|
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
||||||
boolean isPreviousMessageFriendRequest = previous.orNull() != null && friendRequestDatabase.isFriendRequest(previous.get().id);
|
boolean isPreviousMessageFriendRequest = previous.orNull() != null && lokiMessageDatabase.isFriendRequest(previous.get().id);
|
||||||
|
|
||||||
if (isOutgoingStack && isPreviousMessageFriendRequest) {
|
if (isOutgoingStack && isPreviousMessageFriendRequest) {
|
||||||
spacingTop = readDimen(context, R.dimen.conversation_vertical_message_spacing_default);
|
spacingTop = readDimen(context, R.dimen.conversation_vertical_message_spacing_default);
|
||||||
|
@ -34,9 +34,9 @@ import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
|||||||
import org.thoughtcrime.securesms.loki.LokiAPIDatabase;
|
import org.thoughtcrime.securesms.loki.LokiAPIDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiPreKeyRecordDatabase;
|
import org.thoughtcrime.securesms.loki.LokiPreKeyRecordDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiPreKeyBundleDatabase;
|
import org.thoughtcrime.securesms.loki.LokiPreKeyBundleDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiMessageFriendRequestDatabase;
|
import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
|
import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiUserDisplayNameDatabase;
|
import org.thoughtcrime.securesms.loki.LokiUserDatabase;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
|
||||||
public class DatabaseFactory {
|
public class DatabaseFactory {
|
||||||
@ -70,9 +70,9 @@ public class DatabaseFactory {
|
|||||||
private final LokiAPIDatabase lokiAPIDatabase;
|
private final LokiAPIDatabase lokiAPIDatabase;
|
||||||
private final LokiPreKeyRecordDatabase lokiContactPreKeyDatabase;
|
private final LokiPreKeyRecordDatabase lokiContactPreKeyDatabase;
|
||||||
private final LokiPreKeyBundleDatabase lokiPreKeyBundleDatabase;
|
private final LokiPreKeyBundleDatabase lokiPreKeyBundleDatabase;
|
||||||
private final LokiMessageFriendRequestDatabase lokiMessageFriendRequestDatabase;
|
private final LokiMessageDatabase lokiMessageDatabase;
|
||||||
private final LokiThreadDatabase lokiThreadDatabase;
|
private final LokiThreadDatabase lokiThreadDatabase;
|
||||||
private final LokiUserDisplayNameDatabase lokiUserDisplayNameDatabase;
|
private final LokiUserDatabase lokiUserDatabase;
|
||||||
|
|
||||||
public static DatabaseFactory getInstance(Context context) {
|
public static DatabaseFactory getInstance(Context context) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
@ -176,16 +176,16 @@ public class DatabaseFactory {
|
|||||||
return getInstance(context).lokiPreKeyBundleDatabase;
|
return getInstance(context).lokiPreKeyBundleDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LokiMessageFriendRequestDatabase getLokiMessageFriendRequestDatabase(Context context) {
|
public static LokiMessageDatabase getLokiMessageDatabase(Context context) {
|
||||||
return getInstance(context).lokiMessageFriendRequestDatabase;
|
return getInstance(context).lokiMessageDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LokiThreadDatabase getLokiThreadDatabase(Context context) {
|
public static LokiThreadDatabase getLokiThreadDatabase(Context context) {
|
||||||
return getInstance(context).lokiThreadDatabase;
|
return getInstance(context).lokiThreadDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LokiUserDisplayNameDatabase getLokiUserDisplayNameDatabase(Context context) {
|
public static LokiUserDatabase getLokiUserDatabase(Context context) {
|
||||||
return getInstance(context).lokiUserDisplayNameDatabase;
|
return getInstance(context).lokiUserDatabase;
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
@ -223,9 +223,9 @@ public class DatabaseFactory {
|
|||||||
this.lokiAPIDatabase = new LokiAPIDatabase(context, databaseHelper);
|
this.lokiAPIDatabase = new LokiAPIDatabase(context, databaseHelper);
|
||||||
this.lokiContactPreKeyDatabase = new LokiPreKeyRecordDatabase(context, databaseHelper);
|
this.lokiContactPreKeyDatabase = new LokiPreKeyRecordDatabase(context, databaseHelper);
|
||||||
this.lokiPreKeyBundleDatabase = new LokiPreKeyBundleDatabase(context, databaseHelper);
|
this.lokiPreKeyBundleDatabase = new LokiPreKeyBundleDatabase(context, databaseHelper);
|
||||||
this.lokiMessageFriendRequestDatabase = new LokiMessageFriendRequestDatabase(context, databaseHelper);
|
this.lokiMessageDatabase = new LokiMessageDatabase(context, databaseHelper);
|
||||||
this.lokiThreadDatabase = new LokiThreadDatabase(context, databaseHelper);
|
this.lokiThreadDatabase = new LokiThreadDatabase(context, databaseHelper);
|
||||||
this.lokiUserDisplayNameDatabase = new LokiUserDisplayNameDatabase(context, databaseHelper);
|
this.lokiUserDatabase = new LokiUserDatabase(context, databaseHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onApplicationLevelUpgrade(@NonNull Context context, @NonNull MasterSecret masterSecret,
|
public void onApplicationLevelUpgrade(@NonNull Context context, @NonNull MasterSecret masterSecret,
|
||||||
|
@ -531,11 +531,6 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
updateMessageBodyAndType(messageId, body, Types.ENCRYPTION_MASK, type);
|
updateMessageBodyAndType(messageId, body, Types.ENCRYPTION_MASK, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMessageID(long oldMessageID, long newMessageID) {
|
|
||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
|
||||||
db.execSQL("UPDATE " + TABLE_NAME + " SET " + ID + " = ? WHERE " + ID + " = ?", new String[] { newMessageID + "", oldMessageID + "" });
|
|
||||||
}
|
|
||||||
|
|
||||||
private Pair<Long, Long> updateMessageBodyAndType(long messageId, String body, long maskOff, long maskOn) {
|
private Pair<Long, Long> updateMessageBodyAndType(long messageId, String body, long maskOff, long maskOn) {
|
||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||||
db.execSQL("UPDATE " + TABLE_NAME + " SET " + BODY + " = ?, " +
|
db.execSQL("UPDATE " + TABLE_NAME + " SET " + BODY + " = ?, " +
|
||||||
|
@ -891,7 +891,7 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
Recipient recipient = Recipient.from(context, address, true);
|
Recipient recipient = Recipient.from(context, address, true);
|
||||||
|
|
||||||
// Loki - Check to see if this message was a friend request
|
// Loki - Check to see if this message was a friend request
|
||||||
boolean isFriendRequest = DatabaseFactory.getLokiMessageFriendRequestDatabase(context).isFriendRequest(messageId);
|
boolean isFriendRequest = DatabaseFactory.getLokiMessageDatabase(context).isFriendRequest(messageId);
|
||||||
|
|
||||||
return new SmsMessageRecord(messageId, body, recipient,
|
return new SmsMessageRecord(messageId, body, recipient,
|
||||||
recipient,
|
recipient,
|
||||||
|
@ -37,10 +37,10 @@ import org.thoughtcrime.securesms.jobs.RefreshPreKeysJob;
|
|||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.loki.LokiAPIDatabase;
|
import org.thoughtcrime.securesms.loki.LokiAPIDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiPreKeyRecordDatabase;
|
import org.thoughtcrime.securesms.loki.LokiPreKeyRecordDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiMessageFriendRequestDatabase;
|
import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiPreKeyBundleDatabase;
|
import org.thoughtcrime.securesms.loki.LokiPreKeyBundleDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
|
import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiUserDisplayNameDatabase;
|
import org.thoughtcrime.securesms.loki.LokiUserDatabase;
|
||||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
@ -126,10 +126,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||||||
db.execSQL(LokiAPIDatabase.getCreateReceivedMessageHashValuesTableCommand());
|
db.execSQL(LokiAPIDatabase.getCreateReceivedMessageHashValuesTableCommand());
|
||||||
db.execSQL(LokiPreKeyBundleDatabase.getCreateTableCommand());
|
db.execSQL(LokiPreKeyBundleDatabase.getCreateTableCommand());
|
||||||
db.execSQL(LokiPreKeyRecordDatabase.getCreateTableCommand());
|
db.execSQL(LokiPreKeyRecordDatabase.getCreateTableCommand());
|
||||||
db.execSQL(LokiMessageFriendRequestDatabase.getCreateTableCommand());
|
db.execSQL(LokiMessageDatabase.getCreateTableCommand());
|
||||||
db.execSQL(LokiThreadDatabase.getCreateFriendRequestTableCommand());
|
db.execSQL(LokiThreadDatabase.getCreateFriendRequestTableCommand());
|
||||||
db.execSQL(LokiThreadDatabase.getCreateSessionResetTableCommand());
|
db.execSQL(LokiThreadDatabase.getCreateSessionResetTableCommand());
|
||||||
db.execSQL(LokiUserDisplayNameDatabase.getCreateTableCommand());
|
db.execSQL(LokiUserDatabase.getCreateTableCommand());
|
||||||
|
|
||||||
executeStatements(db, SmsDatabase.CREATE_INDEXS);
|
executeStatements(db, SmsDatabase.CREATE_INDEXS);
|
||||||
executeStatements(db, MmsDatabase.CREATE_INDEXS);
|
executeStatements(db, MmsDatabase.CREATE_INDEXS);
|
||||||
|
@ -155,9 +155,10 @@ public class SignalCommunicationModule {
|
|||||||
TextSecurePreferences.getLocalNumber(context),
|
TextSecurePreferences.getLocalNumber(context),
|
||||||
DatabaseFactory.getLokiAPIDatabase(context),
|
DatabaseFactory.getLokiAPIDatabase(context),
|
||||||
DatabaseFactory.getLokiThreadDatabase(context),
|
DatabaseFactory.getLokiThreadDatabase(context),
|
||||||
DatabaseFactory.getLokiMessageFriendRequestDatabase(context),
|
DatabaseFactory.getLokiMessageDatabase(context),
|
||||||
DatabaseFactory.getLokiPreKeyBundleDatabase(context),
|
DatabaseFactory.getLokiPreKeyBundleDatabase(context),
|
||||||
new TextSecureSessionStore(context));
|
new TextSecureSessionStore(context),
|
||||||
|
DatabaseFactory.getLokiUserDatabase(context));
|
||||||
} else {
|
} else {
|
||||||
this.messageSender.setMessagePipe(IncomingMessageObserver.getPipe(), IncomingMessageObserver.getUnidentifiedPipe());
|
this.messageSender.setMessagePipe(IncomingMessageObserver.getPipe(), IncomingMessageObserver.getUnidentifiedPipe());
|
||||||
this.messageSender.setIsMultiDevice(TextSecurePreferences.isMultiDevice(context));
|
this.messageSender.setIsMultiDevice(TextSecurePreferences.isMultiDevice(context));
|
||||||
|
@ -68,7 +68,7 @@ import org.thoughtcrime.securesms.linkpreview.Link;
|
|||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil;
|
import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.loki.LokiMessageFriendRequestDatabase;
|
import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiPreKeyBundleDatabase;
|
import org.thoughtcrime.securesms.loki.LokiPreKeyBundleDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiPreKeyRecordDatabase;
|
import org.thoughtcrime.securesms.loki.LokiPreKeyRecordDatabase;
|
||||||
import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
|
import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
|
||||||
@ -280,9 +280,9 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
Log.d("Loki", "Received a pre key bundle from: " + envelope.getSource() + ".");
|
Log.d("Loki", "Received a pre key bundle from: " + envelope.getSource() + ".");
|
||||||
int registrationID = TextSecurePreferences.getLocalRegistrationId(context);
|
int registrationID = TextSecurePreferences.getLocalRegistrationId(context);
|
||||||
if (registrationID > 0) {
|
if (registrationID > 0) {
|
||||||
LokiPreKeyBundleDatabase preKeyBundleDatabase = DatabaseFactory.getLokiPreKeyBundleDatabase(context);
|
LokiPreKeyBundleDatabase lokiPreKeyBundleDatabase = DatabaseFactory.getLokiPreKeyBundleDatabase(context);
|
||||||
PreKeyBundle preKeyBundle = lokiMessage.getPreKeyBundleMessage().getPreKeyBundle(registrationID);
|
PreKeyBundle preKeyBundle = lokiMessage.getPreKeyBundleMessage().getPreKeyBundle(registrationID);
|
||||||
preKeyBundleDatabase.setPreKeyBundle(envelope.getSource(), preKeyBundle);
|
lokiPreKeyBundleDatabase.setPreKeyBundle(envelope.getSource(), preKeyBundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lokiMessage.getAddressMessage() != null) {
|
if (lokiMessage.getAddressMessage() != null) {
|
||||||
@ -293,7 +293,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
// Loki - Get the sender display name if needed
|
// Loki - Get the sender display name if needed
|
||||||
Optional<String> senderDisplayName = content.senderDisplayName;
|
Optional<String> senderDisplayName = content.senderDisplayName;
|
||||||
if (senderDisplayName.isPresent()) {
|
if (senderDisplayName.isPresent()) {
|
||||||
DatabaseFactory.getLokiUserDisplayNameDatabase(context).setDisplayName(envelope.getSource(), senderDisplayName.get());
|
DatabaseFactory.getLokiUserDatabase(context).setDisplayName(envelope.getSource(), senderDisplayName.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.getDataMessage().isPresent()) {
|
if (content.getDataMessage().isPresent()) {
|
||||||
@ -938,28 +938,28 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
// If we get anything other than a friend request, we can assume that we have a session with the other user
|
// If we get anything other than a friend request, we can assume that we have a session with the other user
|
||||||
if (envelope.isFriendRequest()) { return; }
|
if (envelope.isFriendRequest()) { return; }
|
||||||
Recipient contactID = Recipient.from(context, Address.fromSerialized(content.getSender()), false);
|
Recipient contactID = Recipient.from(context, Address.fromSerialized(content.getSender()), false);
|
||||||
LokiThreadDatabase threadDatabase = DatabaseFactory.getLokiThreadDatabase(context);
|
LokiThreadDatabase lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context);
|
||||||
long threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(contactID);
|
long threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(contactID);
|
||||||
LokiThreadFriendRequestStatus threadFriendRequestStatus = threadDatabase.getFriendRequestStatus(threadID);
|
LokiThreadFriendRequestStatus threadFriendRequestStatus = lokiThreadDatabase.getFriendRequestStatus(threadID);
|
||||||
if (threadFriendRequestStatus == LokiThreadFriendRequestStatus.FRIENDS) { return; }
|
if (threadFriendRequestStatus == LokiThreadFriendRequestStatus.FRIENDS) { return; }
|
||||||
SmsDatabase messageDatabase = DatabaseFactory.getSmsDatabase(context);
|
SmsDatabase messageDatabase = DatabaseFactory.getSmsDatabase(context);
|
||||||
LokiMessageFriendRequestDatabase messageFriendRequestDatabase = DatabaseFactory.getLokiMessageFriendRequestDatabase(context);
|
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
||||||
int messageCount = messageDatabase.getMessageCountForThread(threadID);
|
int messageCount = messageDatabase.getMessageCountForThread(threadID);
|
||||||
// If the thread's friend request status is not `FRIENDS`, but we're receiving a message,
|
// If the thread's friend request status is not `FRIENDS`, but we're receiving a message,
|
||||||
// it must be a friend request accepted message. Declining a friend request doesn't send a message.
|
// it must be a friend request accepted message. Declining a friend request doesn't send a message.
|
||||||
threadDatabase.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.FRIENDS);
|
lokiThreadDatabase.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.FRIENDS);
|
||||||
long messageID = messageDatabase.getIDForMessageAtIndex(threadID, messageCount - 1);
|
long messageID = messageDatabase.getIDForMessageAtIndex(threadID, messageCount - 1);
|
||||||
messageFriendRequestDatabase.setFriendRequestStatus(messageID, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED);
|
lokiMessageDatabase.setFriendRequestStatus(messageID, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFriendRequestStatusIfNeeded(@NonNull SignalServiceEnvelope envelope, @NonNull SignalServiceContent content, @NonNull SignalServiceDataMessage message) {
|
private void updateFriendRequestStatusIfNeeded(@NonNull SignalServiceEnvelope envelope, @NonNull SignalServiceContent content, @NonNull SignalServiceDataMessage message) {
|
||||||
if (!envelope.isFriendRequest()) { return; }
|
if (!envelope.isFriendRequest()) { return; }
|
||||||
Recipient contactID = getMessageDestination(content, message);
|
Recipient contactID = getMessageDestination(content, message);
|
||||||
LokiThreadDatabase threadDatabase = DatabaseFactory.getLokiThreadDatabase(context);
|
LokiThreadDatabase lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context);
|
||||||
long threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(contactID);
|
long threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(contactID);
|
||||||
LokiThreadFriendRequestStatus threadFriendRequestStatus = threadDatabase.getFriendRequestStatus(threadID);
|
LokiThreadFriendRequestStatus threadFriendRequestStatus = lokiThreadDatabase.getFriendRequestStatus(threadID);
|
||||||
SmsDatabase messageDatabase = DatabaseFactory.getSmsDatabase(context);
|
SmsDatabase messageDatabase = DatabaseFactory.getSmsDatabase(context);
|
||||||
LokiMessageFriendRequestDatabase messageFriendRequestDatabase = DatabaseFactory.getLokiMessageFriendRequestDatabase(context);
|
LokiMessageDatabase lokiMessageDatabase= DatabaseFactory.getLokiMessageDatabase(context);
|
||||||
int messageCount = messageDatabase.getMessageCountForThread(threadID);
|
int messageCount = messageDatabase.getMessageCountForThread(threadID);
|
||||||
if (threadFriendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_SENT) {
|
if (threadFriendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_SENT) {
|
||||||
// This can happen if Alice sent Bob a friend request, Bob declined, but then Bob changed his
|
// This can happen if Alice sent Bob a friend request, Bob declined, but then Bob changed his
|
||||||
@ -972,9 +972,9 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
// before updating Alice's thread's friend request status to `FRIENDS`,
|
// before updating Alice's thread's friend request status to `FRIENDS`,
|
||||||
// we can end up in a deadlock where both users' threads' friend request statuses are
|
// we can end up in a deadlock where both users' threads' friend request statuses are
|
||||||
// `REQUEST_SENT`.
|
// `REQUEST_SENT`.
|
||||||
threadDatabase.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.FRIENDS);
|
lokiThreadDatabase.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.FRIENDS);
|
||||||
long messageID = messageDatabase.getIDForMessageAtIndex(threadID, messageCount - 2); // The message before the one that was just received
|
long messageID = messageDatabase.getIDForMessageAtIndex(threadID, messageCount - 2); // The message before the one that was just received
|
||||||
messageFriendRequestDatabase.setFriendRequestStatus(messageID, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED);
|
lokiMessageDatabase.setFriendRequestStatus(messageID, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED);
|
||||||
// Accept the friend request
|
// Accept the friend request
|
||||||
sendBackgroundMessage(content.getSender());
|
sendBackgroundMessage(content.getSender());
|
||||||
} else if (threadFriendRequestStatus != LokiThreadFriendRequestStatus.FRIENDS) {
|
} else if (threadFriendRequestStatus != LokiThreadFriendRequestStatus.FRIENDS) {
|
||||||
@ -983,9 +983,9 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
// friend request status is reset to `NONE`. Bob now sends Alice a friend
|
// friend request status is reset to `NONE`. Bob now sends Alice a friend
|
||||||
// request. Alice's thread's friend request status is reset to
|
// request. Alice's thread's friend request status is reset to
|
||||||
// `REQUEST_RECEIVED`.
|
// `REQUEST_RECEIVED`.
|
||||||
threadDatabase.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.REQUEST_RECEIVED);
|
lokiThreadDatabase.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.REQUEST_RECEIVED);
|
||||||
long messageID = messageDatabase.getIDForMessageAtIndex(threadID, messageCount - 1); // The message that was just received
|
long messageID = messageDatabase.getIDForMessageAtIndex(threadID, messageCount - 1); // The message that was just received
|
||||||
messageFriendRequestDatabase.setFriendRequestStatus(messageID, LokiMessageFriendRequestStatus.REQUEST_PENDING);
|
lokiMessageDatabase.setFriendRequestStatus(messageID, LokiMessageFriendRequestStatus.REQUEST_PENDING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
|||||||
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
|
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
|
||||||
|
import org.whispersystems.signalservice.loki.api.LokiGroupChatAPI;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -278,7 +279,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
|||||||
|
|
||||||
private @NonNull List<Address> getGroupMessageRecipients(String groupId, long messageId) {
|
private @NonNull List<Address> getGroupMessageRecipients(String groupId, long messageId) {
|
||||||
ArrayList<Address> result = new ArrayList<>();
|
ArrayList<Address> result = new ArrayList<>();
|
||||||
result.add(Address.fromSerialized("network.loki.messenger.publicChat"));
|
result.add(Address.fromSerialized(LokiGroupChatAPI.getServerURL()));
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -28,9 +28,9 @@ class BackgroundPollWorker : PersistentAlarmManagerListener() {
|
|||||||
override fun onAlarm(context: Context, scheduledTime: Long): Long {
|
override fun onAlarm(context: Context, scheduledTime: Long): Long {
|
||||||
if (scheduledTime != 0L) {
|
if (scheduledTime != 0L) {
|
||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
val apiDatabase = DatabaseFactory.getLokiAPIDatabase(context)
|
val lokiAPIDatabase = DatabaseFactory.getLokiAPIDatabase(context)
|
||||||
try {
|
try {
|
||||||
LokiAPI(userHexEncodedPublicKey, apiDatabase).getMessages().get().forEach {
|
LokiAPI(userHexEncodedPublicKey, lokiAPIDatabase).getMessages().get().forEach {
|
||||||
PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it))
|
PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it))
|
||||||
}
|
}
|
||||||
} catch (exception: Throwable) {
|
} catch (exception: Throwable) {
|
||||||
|
@ -106,13 +106,13 @@ class FriendRequestView(context: Context, attrs: AttributeSet?, defStyleAttr: In
|
|||||||
|
|
||||||
private fun updateUI() {
|
private fun updateUI() {
|
||||||
val message = message
|
val message = message
|
||||||
val database = DatabaseFactory.getLokiMessageFriendRequestDatabase(context)
|
val lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context)
|
||||||
val contactID = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(message!!.threadId)!!.address.toString()
|
val contactID = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(message!!.threadId)!!.address.toString()
|
||||||
val contactDisplayName = DatabaseFactory.getLokiUserDisplayNameDatabase(context).getDisplayName(contactID) ?: contactID
|
val contactDisplayName = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(contactID) ?: contactID
|
||||||
if (message is MediaMmsMessageRecord && message.quote != null) { visibility = View.GONE; return }
|
if (message is MediaMmsMessageRecord && message.quote != null) { visibility = View.GONE; return }
|
||||||
val isTextMessage = message is SmsMessageRecord
|
val isTextMessage = message is SmsMessageRecord
|
||||||
if (!isTextMessage) return
|
if (!isTextMessage) return
|
||||||
val friendRequestStatus = database.getFriendRequestStatus(message.id)
|
val friendRequestStatus = lokiMessageDatabase.getFriendRequestStatus(message.id)
|
||||||
if (!message.isOutgoing) {
|
if (!message.isOutgoing) {
|
||||||
visibility = if (friendRequestStatus == LokiMessageFriendRequestStatus.NONE) View.GONE else View.VISIBLE
|
visibility = if (friendRequestStatus == LokiMessageFriendRequestStatus.NONE) View.GONE else View.VISIBLE
|
||||||
buttonLinearLayout.visibility = if (friendRequestStatus != LokiMessageFriendRequestStatus.REQUEST_PENDING) View.GONE else View.VISIBLE
|
buttonLinearLayout.visibility = if (friendRequestStatus != LokiMessageFriendRequestStatus.REQUEST_PENDING) View.GONE else View.VISIBLE
|
||||||
@ -147,15 +147,15 @@ class FriendRequestView(context: Context, attrs: AttributeSet?, defStyleAttr: In
|
|||||||
|
|
||||||
// region Interaction
|
// region Interaction
|
||||||
private fun accept() {
|
private fun accept() {
|
||||||
val database = DatabaseFactory.getLokiMessageFriendRequestDatabase(context)
|
val lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context)
|
||||||
database.setFriendRequestStatus(message!!.id, LokiMessageFriendRequestStatus.REQUEST_SENDING)
|
lokiMessageDatabase.setFriendRequestStatus(message!!.id, LokiMessageFriendRequestStatus.REQUEST_SENDING)
|
||||||
updateUI()
|
updateUI()
|
||||||
delegate?.acceptFriendRequest(message!!)
|
delegate?.acceptFriendRequest(message!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reject() {
|
private fun reject() {
|
||||||
val database = DatabaseFactory.getLokiMessageFriendRequestDatabase(context)
|
val lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context)
|
||||||
database.setFriendRequestStatus(message!!.id, LokiMessageFriendRequestStatus.REQUEST_REJECTED)
|
lokiMessageDatabase.setFriendRequestStatus(message!!.id, LokiMessageFriendRequestStatus.REQUEST_REJECTED)
|
||||||
updateUI()
|
updateUI()
|
||||||
delegate?.rejectFriendRequest(message!!)
|
delegate?.rejectFriendRequest(message!!)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package org.thoughtcrime.securesms.loki
|
|||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import org.thoughtcrime.securesms.database.Database
|
import org.thoughtcrime.securesms.database.Database
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
|
||||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.signalservice.loki.api.LokiAPIDatabaseProtocol
|
import org.whispersystems.signalservice.loki.api.LokiAPIDatabaseProtocol
|
||||||
@ -78,15 +77,6 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
val row = wrap(mapOf( userID to userPublicKey, receivedMessageHashValues to receivedMessageHashValuesAsString ))
|
val row = wrap(mapOf( userID to userPublicKey, receivedMessageHashValues to receivedMessageHashValuesAsString ))
|
||||||
database.insertOrUpdate(receivedMessageHashValuesCache, row, "$userID = ?", wrap(userPublicKey))
|
database.insertOrUpdate(receivedMessageHashValuesCache, row, "$userID = ?", wrap(userPublicKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getUserDisplayName(): String? {
|
|
||||||
return TextSecurePreferences.getProfileName(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateMessageIDIfNeeded(signalID: Long, lokiID: Long) {
|
|
||||||
if (signalID == lokiID) return
|
|
||||||
DatabaseFactory.getMmsDatabase(context).updateMessageID(signalID, lokiID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// region Convenience
|
// region Convenience
|
||||||
|
@ -41,10 +41,10 @@ class LokiGroupChatPoller(private val context: Context, private val groupID: Lon
|
|||||||
|
|
||||||
private fun poll() {
|
private fun poll() {
|
||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
val database = DatabaseFactory.getLokiAPIDatabase(context)
|
val lokiUserDatabase = DatabaseFactory.getLokiUserDatabase(context)
|
||||||
LokiGroupChatAPI(userHexEncodedPublicKey, database).getMessages(groupID).success { messages ->
|
LokiGroupChatAPI(userHexEncodedPublicKey, lokiUserDatabase).getMessages(groupID).success { messages ->
|
||||||
messages.map { message ->
|
messages.map { message ->
|
||||||
val id = "loki-group-chat-$groupID".toByteArray()
|
val id = "${LokiGroupChatAPI.serverURL}.$groupID".toByteArray()
|
||||||
val x1 = SignalServiceGroup(SignalServiceGroup.Type.UPDATE, id, null, null, null)
|
val x1 = SignalServiceGroup(SignalServiceGroup.Type.UPDATE, id, null, null, null)
|
||||||
val x2 = SignalServiceDataMessage(message.timestamp, x1, null, message.body)
|
val x2 = SignalServiceDataMessage(message.timestamp, x1, null, message.body)
|
||||||
val senderDisplayName = "${message.displayName} (...${message.hexEncodedPublicKey.takeLast(8)})"
|
val senderDisplayName = "${message.displayName} (...${message.hexEncodedPublicKey.takeLast(8)})"
|
||||||
|
@ -8,13 +8,22 @@ import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
|||||||
import org.whispersystems.signalservice.loki.messaging.LokiMessageDatabaseProtocol
|
import org.whispersystems.signalservice.loki.messaging.LokiMessageDatabaseProtocol
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus
|
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus
|
||||||
|
|
||||||
class LokiMessageFriendRequestDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiMessageDatabaseProtocol {
|
class LokiMessageDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiMessageDatabaseProtocol {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val tableName = "loki_message_friend_request_database"
|
private val tableName = "loki_message_friend_request_database"
|
||||||
private val messageID = "message_id"
|
private val messageID = "message_id"
|
||||||
|
private val serverID = "server_id"
|
||||||
private val friendRequestStatus = "friend_request_status"
|
private val friendRequestStatus = "friend_request_status"
|
||||||
@JvmStatic val createTableCommand = "CREATE TABLE $tableName ($messageID INTEGER PRIMARY KEY, $friendRequestStatus INTEGER DEFAULT 0);"
|
@JvmStatic val createTableCommand = "CREATE TABLE $tableName ($messageID INTEGER PRIMARY KEY, $serverID INTEGER DEFAULT 0, $friendRequestStatus INTEGER DEFAULT 0);"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setServerID(messageID: Long, serverID: Long) {
|
||||||
|
val database = databaseHelper.writableDatabase
|
||||||
|
val contentValues = ContentValues(2)
|
||||||
|
contentValues.put(Companion.messageID, messageID)
|
||||||
|
contentValues.put(Companion.serverID, serverID)
|
||||||
|
database.insertOrUpdate(tableName, contentValues, "${Companion.messageID} = ?", arrayOf( messageID.toString() ))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFriendRequestStatus(messageID: Long): LokiMessageFriendRequestStatus {
|
override fun getFriendRequestStatus(messageID: Long): LokiMessageFriendRequestStatus {
|
@ -6,8 +6,10 @@ import org.thoughtcrime.securesms.database.Address
|
|||||||
import org.thoughtcrime.securesms.database.Database
|
import org.thoughtcrime.securesms.database.Database
|
||||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
|
import org.whispersystems.signalservice.loki.messaging.LokiUserDatabaseProtocol
|
||||||
|
|
||||||
class LokiUserDisplayNameDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) {
|
class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiUserDatabaseProtocol {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val tableName = "loki_user_display_name_database"
|
private val tableName = "loki_user_display_name_database"
|
||||||
@ -16,10 +18,14 @@ class LokiUserDisplayNameDatabase(context: Context, helper: SQLCipherOpenHelper)
|
|||||||
@JvmStatic val createTableCommand = "CREATE TABLE $tableName ($hexEncodedPublicKey TEXT PRIMARY KEY, $displayName TEXT);"
|
@JvmStatic val createTableCommand = "CREATE TABLE $tableName ($hexEncodedPublicKey TEXT PRIMARY KEY, $displayName TEXT);"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDisplayName(hexEncodedPublicKey: String): String? {
|
override fun getDisplayName(hexEncodedPublicKey: String): String? {
|
||||||
val database = databaseHelper.readableDatabase
|
if (hexEncodedPublicKey == TextSecurePreferences.getLocalNumber(context)) {
|
||||||
return database.get(tableName, "${Companion.hexEncodedPublicKey} = ?", arrayOf( hexEncodedPublicKey )) { cursor ->
|
return TextSecurePreferences.getProfileName(context)
|
||||||
cursor.getString(cursor.getColumnIndexOrThrow(displayName))
|
} else {
|
||||||
|
val database = databaseHelper.readableDatabase
|
||||||
|
return database.get(tableName, "${Companion.hexEncodedPublicKey} = ?", arrayOf(hexEncodedPublicKey)) { cursor ->
|
||||||
|
cursor.getString(cursor.getColumnIndexOrThrow(displayName))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,9 +86,9 @@ public class MarkReadReceiver extends BroadcastReceiver {
|
|||||||
.collect(Collectors.groupingBy(SyncMessageId::getAddress));
|
.collect(Collectors.groupingBy(SyncMessageId::getAddress));
|
||||||
|
|
||||||
for (Address address : addressMap.keySet()) {
|
for (Address address : addressMap.keySet()) {
|
||||||
LokiThreadDatabase threadDatabase = DatabaseFactory.getLokiThreadDatabase(context);
|
LokiThreadDatabase lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context);
|
||||||
long threadID = threadDatabase.getThreadID(address.serialize());
|
long threadID = lokiThreadDatabase.getThreadID(address.serialize());
|
||||||
LokiThreadFriendRequestStatus friendRequestStatus = threadDatabase.getFriendRequestStatus(threadID);
|
LokiThreadFriendRequestStatus friendRequestStatus = lokiThreadDatabase.getFriendRequestStatus(threadID);
|
||||||
if (friendRequestStatus != LokiThreadFriendRequestStatus.FRIENDS) { return; }
|
if (friendRequestStatus != LokiThreadFriendRequestStatus.FRIENDS) { return; }
|
||||||
|
|
||||||
List<Long> timestamps = Stream.of(addressMap.get(address)).map(SyncMessageId::getTimetamp).toList();
|
List<Long> timestamps = Stream.of(addressMap.get(address)).map(SyncMessageId::getTimetamp).toList();
|
||||||
|
@ -26,7 +26,6 @@ import android.text.TextUtils;
|
|||||||
|
|
||||||
import com.annimon.stream.function.Consumer;
|
import com.annimon.stream.function.Consumer;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
|
import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||||
@ -60,6 +59,8 @@ import java.util.Set;
|
|||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import network.loki.messenger.R;
|
||||||
|
|
||||||
public class Recipient implements RecipientModifiedListener {
|
public class Recipient implements RecipientModifiedListener {
|
||||||
|
|
||||||
private static final String TAG = Recipient.class.getSimpleName();
|
private static final String TAG = Recipient.class.getSimpleName();
|
||||||
@ -292,7 +293,7 @@ public class Recipient implements RecipientModifiedListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized @Nullable String getName() {
|
public synchronized @Nullable String getName() {
|
||||||
String displayName = DatabaseFactory.getLokiUserDisplayNameDatabase(context).getDisplayName(this.address.toString());
|
String displayName = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(this.address.toString());
|
||||||
if (displayName != null) { return displayName; }
|
if (displayName != null) { return displayName; }
|
||||||
|
|
||||||
if (this.name == null && isMmsGroupRecipient()) {
|
if (this.name == null && isMmsGroupRecipient()) {
|
||||||
|
@ -79,7 +79,7 @@ public class MessageSender {
|
|||||||
|
|
||||||
// Loki - Set the message's friend request status as soon as it has hit the database
|
// Loki - Set the message's friend request status as soon as it has hit the database
|
||||||
if (message.isFriendRequest) {
|
if (message.isFriendRequest) {
|
||||||
DatabaseFactory.getLokiMessageFriendRequestDatabase(context).setFriendRequestStatus(messageId, LokiMessageFriendRequestStatus.REQUEST_SENDING);
|
DatabaseFactory.getLokiMessageDatabase(context).setFriendRequestStatus(messageId, LokiMessageFriendRequestStatus.REQUEST_SENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendTextMessage(context, recipient, forceSms, keyExchange, messageId);
|
sendTextMessage(context, recipient, forceSms, keyExchange, messageId);
|
||||||
|
Loading…
Reference in New Issue
Block a user