mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Merge pull request #2219 from nextcloud/chore/1549/roomMigration2
Migrate calls and used classes/methods from requery to room
This commit is contained in:
commit
1c672c04e3
@ -189,26 +189,18 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
|
|||||||
Log.d(TAG, this.toString())
|
Log.d(TAG, this.toString())
|
||||||
timestamp = System.currentTimeMillis()
|
timestamp = System.currentTimeMillis()
|
||||||
if (delete) {
|
if (delete) {
|
||||||
cancelExistingNotificationWithId(
|
cancelExistingNotificationWithId(applicationContext, signatureVerification!!.user!!, notificationId)
|
||||||
applicationContext,
|
|
||||||
signatureVerification!!.userEntity!!,
|
|
||||||
notificationId
|
|
||||||
)
|
|
||||||
} else if (deleteAll) {
|
} else if (deleteAll) {
|
||||||
cancelAllNotificationsForAccount(applicationContext, signatureVerification!!.userEntity!!)
|
cancelAllNotificationsForAccount(applicationContext, signatureVerification!!.user!!)
|
||||||
} else if (deleteMultiple) {
|
} else if (deleteMultiple) {
|
||||||
notificationIds!!.forEach {
|
notificationIds!!.forEach {
|
||||||
cancelExistingNotificationWithId(
|
cancelExistingNotificationWithId(applicationContext, signatureVerification!!.user!!, it)
|
||||||
applicationContext,
|
|
||||||
signatureVerification!!.userEntity!!,
|
|
||||||
it
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else if (type == "call") {
|
} else if (type == "call") {
|
||||||
val fullScreenIntent = Intent(applicationContext, CallNotificationActivity::class.java)
|
val fullScreenIntent = Intent(applicationContext, CallNotificationActivity::class.java)
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
bundle.putString(BundleKeys.KEY_ROOM_ID, decryptedPushMessage!!.id)
|
bundle.putString(BundleKeys.KEY_ROOM_ID, decryptedPushMessage!!.id)
|
||||||
bundle.putParcelable(KEY_USER_ENTITY, signatureVerification!!.userEntity)
|
bundle.putParcelable(KEY_USER_ENTITY, signatureVerification!!.user)
|
||||||
bundle.putBoolean(KEY_FROM_NOTIFICATION_START_CALL, true)
|
bundle.putBoolean(KEY_FROM_NOTIFICATION_START_CALL, true)
|
||||||
fullScreenIntent.putExtras(bundle)
|
fullScreenIntent.putExtras(bundle)
|
||||||
|
|
||||||
@ -226,7 +218,7 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
|
|||||||
|
|
||||||
val soundUri = getCallRingtoneUri(applicationContext!!, appPreferences)
|
val soundUri = getCallRingtoneUri(applicationContext!!, appPreferences)
|
||||||
val notificationChannelId = NotificationUtils.NOTIFICATION_CHANNEL_CALLS_V4
|
val notificationChannelId = NotificationUtils.NOTIFICATION_CHANNEL_CALLS_V4
|
||||||
val uri = Uri.parse(signatureVerification!!.userEntity!!.baseUrl)
|
val uri = Uri.parse(signatureVerification!!.user!!.baseUrl)
|
||||||
val baseUrl = uri.host
|
val baseUrl = uri.host
|
||||||
|
|
||||||
val notification =
|
val notification =
|
||||||
@ -274,18 +266,18 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
|
|||||||
var inCallOnDifferentDevice = false
|
var inCallOnDifferentDevice = false
|
||||||
|
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(
|
val apiVersion = ApiUtils.getConversationApiVersion(
|
||||||
signatureVerification.userEntity,
|
signatureVerification.user,
|
||||||
intArrayOf(ApiUtils.APIv4, 1)
|
intArrayOf(ApiUtils.APIv4, 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
ncApi.getPeersForCall(
|
ncApi.getPeersForCall(
|
||||||
ApiUtils.getCredentials(
|
ApiUtils.getCredentials(
|
||||||
signatureVerification.userEntity!!.username,
|
signatureVerification.user!!.username,
|
||||||
signatureVerification.userEntity!!.token
|
signatureVerification.user!!.token
|
||||||
),
|
),
|
||||||
ApiUtils.getUrlForCall(
|
ApiUtils.getUrlForCall(
|
||||||
apiVersion,
|
apiVersion,
|
||||||
signatureVerification.userEntity!!.baseUrl,
|
signatureVerification.user!!.baseUrl,
|
||||||
decryptedPushMessage.id
|
decryptedPushMessage.id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -303,7 +295,7 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
|
|||||||
hasParticipantsInCall = participantList.isNotEmpty()
|
hasParticipantsInCall = participantList.isNotEmpty()
|
||||||
if (hasParticipantsInCall) {
|
if (hasParticipantsInCall) {
|
||||||
for (participant in participantList) {
|
for (participant in participantList) {
|
||||||
if (participant.actorId == signatureVerification.userEntity!!.userId &&
|
if (participant.actorId == signatureVerification.user!!.userId &&
|
||||||
participant.actorType == Participant.ActorType.USERS
|
participant.actorType == Participant.ActorType.USERS
|
||||||
) {
|
) {
|
||||||
inCallOnDifferentDevice = true
|
inCallOnDifferentDevice = true
|
||||||
|
@ -58,6 +58,7 @@ import com.nextcloud.talk.adapters.ParticipantDisplayItem;
|
|||||||
import com.nextcloud.talk.adapters.ParticipantsAdapter;
|
import com.nextcloud.talk.adapters.ParticipantsAdapter;
|
||||||
import com.nextcloud.talk.api.NcApi;
|
import com.nextcloud.talk.api.NcApi;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
|
import com.nextcloud.talk.data.user.model.User;
|
||||||
import com.nextcloud.talk.databinding.CallActivityBinding;
|
import com.nextcloud.talk.databinding.CallActivityBinding;
|
||||||
import com.nextcloud.talk.events.ConfigurationChangeEvent;
|
import com.nextcloud.talk.events.ConfigurationChangeEvent;
|
||||||
import com.nextcloud.talk.events.MediaStreamEvent;
|
import com.nextcloud.talk.events.MediaStreamEvent;
|
||||||
@ -66,7 +67,6 @@ import com.nextcloud.talk.events.PeerConnectionEvent;
|
|||||||
import com.nextcloud.talk.events.SessionDescriptionSendEvent;
|
import com.nextcloud.talk.events.SessionDescriptionSendEvent;
|
||||||
import com.nextcloud.talk.events.WebSocketCommunicationEvent;
|
import com.nextcloud.talk.events.WebSocketCommunicationEvent;
|
||||||
import com.nextcloud.talk.models.ExternalSignalingServer;
|
import com.nextcloud.talk.models.ExternalSignalingServer;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
|
||||||
import com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall;
|
import com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall;
|
||||||
import com.nextcloud.talk.models.json.conversations.Conversation;
|
import com.nextcloud.talk.models.json.conversations.Conversation;
|
||||||
import com.nextcloud.talk.models.json.conversations.RoomOverall;
|
import com.nextcloud.talk.models.json.conversations.RoomOverall;
|
||||||
@ -85,13 +85,12 @@ import com.nextcloud.talk.models.json.signaling.SignalingOverall;
|
|||||||
import com.nextcloud.talk.models.json.signaling.settings.IceServer;
|
import com.nextcloud.talk.models.json.signaling.settings.IceServer;
|
||||||
import com.nextcloud.talk.models.json.signaling.settings.SignalingSettingsOverall;
|
import com.nextcloud.talk.models.json.signaling.settings.SignalingSettingsOverall;
|
||||||
import com.nextcloud.talk.ui.dialog.AudioOutputDialog;
|
import com.nextcloud.talk.ui.dialog.AudioOutputDialog;
|
||||||
|
import com.nextcloud.talk.users.UserManager;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
import com.nextcloud.talk.utils.DisplayUtils;
|
import com.nextcloud.talk.utils.DisplayUtils;
|
||||||
import com.nextcloud.talk.utils.LegacyUserEntityMapper;
|
|
||||||
import com.nextcloud.talk.utils.NotificationUtils;
|
import com.nextcloud.talk.utils.NotificationUtils;
|
||||||
import com.nextcloud.talk.utils.animations.PulseAnimation;
|
import com.nextcloud.talk.utils.animations.PulseAnimation;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
|
||||||
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil;
|
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil;
|
||||||
import com.nextcloud.talk.utils.power.PowerManagerUtils;
|
import com.nextcloud.talk.utils.power.PowerManagerUtils;
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
||||||
@ -181,7 +180,7 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
@Inject
|
@Inject
|
||||||
EventBus eventBus;
|
EventBus eventBus;
|
||||||
@Inject
|
@Inject
|
||||||
UserUtils userUtils;
|
UserManager userManager;
|
||||||
@Inject
|
@Inject
|
||||||
AppPreferences appPreferences;
|
AppPreferences appPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
@ -228,7 +227,7 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
private List<PeerConnection.IceServer> iceServers;
|
private List<PeerConnection.IceServer> iceServers;
|
||||||
private CameraEnumerator cameraEnumerator;
|
private CameraEnumerator cameraEnumerator;
|
||||||
private String roomToken;
|
private String roomToken;
|
||||||
private UserEntity conversationUser;
|
private User conversationUser;
|
||||||
private String conversationName;
|
private String conversationName;
|
||||||
private String callSession;
|
private String callSession;
|
||||||
private MediaStream localStream;
|
private MediaStream localStream;
|
||||||
@ -1209,30 +1208,14 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
}
|
}
|
||||||
Log.d(TAG, " hasExternalSignalingServer: " + hasExternalSignalingServer);
|
Log.d(TAG, " hasExternalSignalingServer: " + hasExternalSignalingServer);
|
||||||
|
|
||||||
if (!conversationUser.getUserId().equals("?")) {
|
if (!"?".equals(conversationUser.getUserId()) && conversationUser.getId() != null) {
|
||||||
try {
|
Log.d(TAG, "Update externalSignalingServer for: " + conversationUser.getId() +
|
||||||
userUtils.createOrUpdateUser(null,
|
" / " + conversationUser.getUserId());
|
||||||
null,
|
userManager.updateExternalSignalingServer(conversationUser.getId(), externalSignalingServer)
|
||||||
null,
|
.subscribeOn(Schedulers.io())
|
||||||
null,
|
.subscribe();
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
conversationUser.getId(),
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
LoganSquare.serialize(externalSignalingServer))
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.subscribe();
|
|
||||||
} catch (IOException exception) {
|
|
||||||
Log.e(TAG, "Failed to serialize external signaling server", exception);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
conversationUser.setExternalSignalingServer(externalSignalingServer);
|
||||||
conversationUser.setExternalSignalingServer(LoganSquare.serialize(externalSignalingServer));
|
|
||||||
} catch (IOException exception) {
|
|
||||||
Log.e(TAG, "Failed to serialize external signaling server", exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
|
if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
|
||||||
@ -1353,8 +1336,7 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
ApplicationWideCurrentRoomHolder.getInstance().setSession(callSession);
|
ApplicationWideCurrentRoomHolder.getInstance().setSession(callSession);
|
||||||
ApplicationWideCurrentRoomHolder.getInstance().setCurrentRoomId(roomId);
|
ApplicationWideCurrentRoomHolder.getInstance().setCurrentRoomId(roomId);
|
||||||
ApplicationWideCurrentRoomHolder.getInstance().setCurrentRoomToken(roomToken);
|
ApplicationWideCurrentRoomHolder.getInstance().setCurrentRoomToken(roomToken);
|
||||||
ApplicationWideCurrentRoomHolder.getInstance().setUserInRoom(
|
ApplicationWideCurrentRoomHolder.getInstance().setUserInRoom(conversationUser);
|
||||||
LegacyUserEntityMapper.toModel(conversationUser));
|
|
||||||
callOrJoinRoomViaWebSocket();
|
callOrJoinRoomViaWebSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1417,7 +1399,7 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
|
|
||||||
if (!TextUtils.isEmpty(roomToken)) {
|
if (!TextUtils.isEmpty(roomToken)) {
|
||||||
NotificationUtils.INSTANCE.cancelExistingNotificationsForRoom(getApplicationContext(),
|
NotificationUtils.INSTANCE.cancelExistingNotificationsForRoom(getApplicationContext(),
|
||||||
Objects.requireNonNull(LegacyUserEntityMapper.toModel(conversationUser)),
|
conversationUser,
|
||||||
roomToken);
|
roomToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,10 +46,9 @@ import com.facebook.imagepipeline.request.ImageRequest;
|
|||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
import com.nextcloud.talk.api.NcApi;
|
import com.nextcloud.talk.api.NcApi;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
|
import com.nextcloud.talk.data.user.model.User;
|
||||||
import com.nextcloud.talk.databinding.CallNotificationActivityBinding;
|
import com.nextcloud.talk.databinding.CallNotificationActivityBinding;
|
||||||
import com.nextcloud.talk.events.CallNotificationClick;
|
import com.nextcloud.talk.events.CallNotificationClick;
|
||||||
import com.nextcloud.talk.models.database.CapabilitiesUtil;
|
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
|
||||||
import com.nextcloud.talk.models.json.conversations.Conversation;
|
import com.nextcloud.talk.models.json.conversations.Conversation;
|
||||||
import com.nextcloud.talk.models.json.conversations.RoomOverall;
|
import com.nextcloud.talk.models.json.conversations.RoomOverall;
|
||||||
import com.nextcloud.talk.models.json.participants.Participant;
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
@ -59,6 +58,7 @@ import com.nextcloud.talk.utils.DisplayUtils;
|
|||||||
import com.nextcloud.talk.utils.DoNotDisturbUtils;
|
import com.nextcloud.talk.utils.DoNotDisturbUtils;
|
||||||
import com.nextcloud.talk.utils.NotificationUtils;
|
import com.nextcloud.talk.utils.NotificationUtils;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
|
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew;
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
@ -106,7 +106,7 @@ public class CallNotificationActivity extends CallBaseActivity {
|
|||||||
private List<Disposable> disposablesList = new ArrayList<>();
|
private List<Disposable> disposablesList = new ArrayList<>();
|
||||||
private Bundle originalBundle;
|
private Bundle originalBundle;
|
||||||
private String roomId;
|
private String roomId;
|
||||||
private UserEntity userBeingCalled;
|
private User userBeingCalled;
|
||||||
private String credentials;
|
private String credentials;
|
||||||
private Conversation currentConversation;
|
private Conversation currentConversation;
|
||||||
private MediaPlayer mediaPlayer;
|
private MediaPlayer mediaPlayer;
|
||||||
@ -285,8 +285,8 @@ public class CallNotificationActivity extends CallBaseActivity {
|
|||||||
|
|
||||||
if (apiVersion >= 3) {
|
if (apiVersion >= 3) {
|
||||||
boolean hasCallFlags =
|
boolean hasCallFlags =
|
||||||
CapabilitiesUtil.hasSpreedFeatureCapability(userBeingCalled,
|
CapabilitiesUtilNew.hasSpreedFeatureCapability(userBeingCalled,
|
||||||
"conversation-call-flags");
|
"conversation-call-flags");
|
||||||
if (hasCallFlags) {
|
if (hasCallFlags) {
|
||||||
if (isInCallWithVideo(currentConversation.getCallFlag())) {
|
if (isInCallWithVideo(currentConversation.getCallFlag())) {
|
||||||
binding.incomingCallVoiceOrVideoTextView.setText(
|
binding.incomingCallVoiceOrVideoTextView.setText(
|
||||||
@ -308,7 +308,7 @@ public class CallNotificationActivity extends CallBaseActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import com.nextcloud.talk.activities.CallActivity;
|
|||||||
import com.nextcloud.talk.activities.MainActivity;
|
import com.nextcloud.talk.activities.MainActivity;
|
||||||
import com.nextcloud.talk.api.NcApi;
|
import com.nextcloud.talk.api.NcApi;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
|
import com.nextcloud.talk.data.user.model.User;
|
||||||
import com.nextcloud.talk.models.SignatureVerification;
|
import com.nextcloud.talk.models.SignatureVerification;
|
||||||
import com.nextcloud.talk.models.database.ArbitraryStorageEntity;
|
import com.nextcloud.talk.models.database.ArbitraryStorageEntity;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
import com.nextcloud.talk.models.database.UserEntity;
|
||||||
@ -130,20 +131,20 @@ public class NotificationWorker extends Worker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showNotificationForCallWithNoPing(Intent intent) {
|
private void showNotificationForCallWithNoPing(Intent intent) {
|
||||||
UserEntity userEntity = signatureVerification.getUserEntity();
|
User user = signatureVerification.getUser();
|
||||||
|
|
||||||
ArbitraryStorageEntity arbitraryStorageEntity;
|
ArbitraryStorageEntity arbitraryStorageEntity;
|
||||||
|
|
||||||
if ((arbitraryStorageEntity = arbitraryStorageUtils.getStorageSetting(
|
if ((arbitraryStorageEntity = arbitraryStorageUtils.getStorageSetting(
|
||||||
userEntity.getId(),
|
user.getId(),
|
||||||
"important_conversation",
|
"important_conversation",
|
||||||
intent.getExtras().getString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN()))) != null) {
|
intent.getExtras().getString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN()))) != null) {
|
||||||
importantConversation = Boolean.parseBoolean(arbitraryStorageEntity.getValue());
|
importantConversation = Boolean.parseBoolean(arbitraryStorageEntity.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
int apiVersion = ApiUtils.getConversationApiVersion(userEntity, new int[] {ApiUtils.APIv4, 1});
|
int apiVersion = ApiUtils.getConversationApiVersion(user, new int[] {ApiUtils.APIv4, 1});
|
||||||
|
|
||||||
ncApi.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, userEntity.getBaseUrl(),
|
ncApi.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, user.getBaseUrl(),
|
||||||
intent.getExtras().getString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN())))
|
intent.getExtras().getString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN())))
|
||||||
.blockingSubscribe(new Observer<RoomOverall>() {
|
.blockingSubscribe(new Observer<RoomOverall>() {
|
||||||
@Override
|
@Override
|
||||||
@ -188,8 +189,8 @@ public class NotificationWorker extends Worker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showNotificationWithObjectData(Intent intent) {
|
private void showNotificationWithObjectData(Intent intent) {
|
||||||
UserEntity userEntity = signatureVerification.getUserEntity();
|
User user = signatureVerification.getUser();
|
||||||
ncApi.getNotification(credentials, ApiUtils.getUrlForNotificationWithId(userEntity.getBaseUrl(),
|
ncApi.getNotification(credentials, ApiUtils.getUrlForNotificationWithId(user.getBaseUrl(),
|
||||||
Long.toString(decryptedPushMessage.getNotificationId())))
|
Long.toString(decryptedPushMessage.getNotificationId())))
|
||||||
.blockingSubscribe(new Observer<NotificationOverall>() {
|
.blockingSubscribe(new Observer<NotificationOverall>() {
|
||||||
@Override
|
@Override
|
||||||
@ -309,7 +310,7 @@ public class NotificationWorker extends Worker {
|
|||||||
}
|
}
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, requestCode, intent, intentFlag);
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, requestCode, intent, intentFlag);
|
||||||
|
|
||||||
Uri uri = Uri.parse(signatureVerification.getUserEntity().getBaseUrl());
|
Uri uri = Uri.parse(signatureVerification.getUser().getBaseUrl());
|
||||||
String baseUrl = uri.getHost();
|
String baseUrl = uri.getHost();
|
||||||
|
|
||||||
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, "1")
|
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, "1")
|
||||||
@ -339,7 +340,7 @@ public class NotificationWorker extends Worker {
|
|||||||
|
|
||||||
Bundle notificationInfo = new Bundle();
|
Bundle notificationInfo = new Bundle();
|
||||||
notificationInfo.putLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(),
|
notificationInfo.putLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(),
|
||||||
signatureVerification.getUserEntity().getId());
|
signatureVerification.getUser().getId());
|
||||||
// could be an ID or a TOKEN
|
// could be an ID or a TOKEN
|
||||||
notificationInfo.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(),
|
notificationInfo.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(),
|
||||||
decryptedPushMessage.getId());
|
decryptedPushMessage.getId());
|
||||||
@ -358,12 +359,13 @@ public class NotificationWorker extends Worker {
|
|||||||
|
|
||||||
notificationBuilder.setContentIntent(pendingIntent);
|
notificationBuilder.setContentIntent(pendingIntent);
|
||||||
|
|
||||||
String groupName = signatureVerification.getUserEntity().getId() + "@" + decryptedPushMessage.getId();
|
String groupName = signatureVerification.getUser().getId() + "@" + decryptedPushMessage.getId();
|
||||||
notificationBuilder.setGroup(Long.toString(calculateCRC32(groupName)));
|
notificationBuilder.setGroup(Long.toString(calculateCRC32(groupName)));
|
||||||
|
|
||||||
StatusBarNotification activeStatusBarNotification =
|
StatusBarNotification activeStatusBarNotification =
|
||||||
NotificationUtils.INSTANCE.findNotificationForRoom(context,
|
NotificationUtils.INSTANCE.findNotificationForRoom(context,
|
||||||
signatureVerification.getUserEntity(), decryptedPushMessage.getId());
|
signatureVerification.getUser(),
|
||||||
|
decryptedPushMessage.getId());
|
||||||
|
|
||||||
// NOTE - systemNotificationId is an internal ID used on the device only.
|
// NOTE - systemNotificationId is an internal ID used on the device only.
|
||||||
// It is NOT the same as the notification ID used in communication with the server.
|
// It is NOT the same as the notification ID used in communication with the server.
|
||||||
@ -404,7 +406,7 @@ public class NotificationWorker extends Worker {
|
|||||||
|
|
||||||
Person.Builder person =
|
Person.Builder person =
|
||||||
new Person.Builder()
|
new Person.Builder()
|
||||||
.setKey(signatureVerification.getUserEntity().getId() + "@" + notificationUser.getId())
|
.setKey(signatureVerification.getUser().getId() + "@" + notificationUser.getId())
|
||||||
.setName(EmojiCompat.get().process(notificationUser.getName()))
|
.setName(EmojiCompat.get().process(notificationUser.getName()))
|
||||||
.setBot("bot".equals(userType));
|
.setBot("bot".equals(userType));
|
||||||
|
|
||||||
@ -413,7 +415,7 @@ public class NotificationWorker extends Worker {
|
|||||||
addMarkAsReadAction(notificationBuilder, systemNotificationId);
|
addMarkAsReadAction(notificationBuilder, systemNotificationId);
|
||||||
|
|
||||||
if ("user".equals(userType) || "guest".equals(userType)) {
|
if ("user".equals(userType) || "guest".equals(userType)) {
|
||||||
String baseUrl = signatureVerification.getUserEntity().getBaseUrl();
|
String baseUrl = signatureVerification.getUser().getBaseUrl();
|
||||||
String avatarUrl = "user".equals(userType) ?
|
String avatarUrl = "user".equals(userType) ?
|
||||||
ApiUtils.getUrlForAvatar(baseUrl, notificationUser.getId(), false) :
|
ApiUtils.getUrlForAvatar(baseUrl, notificationUser.getId(), false) :
|
||||||
ApiUtils.getUrlForGuestAvatar(baseUrl, notificationUser.getName(), false);
|
ApiUtils.getUrlForGuestAvatar(baseUrl, notificationUser.getName(), false);
|
||||||
@ -430,7 +432,7 @@ public class NotificationWorker extends Worker {
|
|||||||
// It is NOT the same as the notification ID used in communication with the server.
|
// It is NOT the same as the notification ID used in communication with the server.
|
||||||
actualIntent.putExtra(BundleKeys.INSTANCE.getKEY_SYSTEM_NOTIFICATION_ID(), systemNotificationId);
|
actualIntent.putExtra(BundleKeys.INSTANCE.getKEY_SYSTEM_NOTIFICATION_ID(), systemNotificationId);
|
||||||
actualIntent.putExtra(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(),
|
actualIntent.putExtra(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(),
|
||||||
Objects.requireNonNull(signatureVerification.getUserEntity()).getId());
|
Objects.requireNonNull(signatureVerification.getUser()).getId());
|
||||||
actualIntent.putExtra(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), decryptedPushMessage.getId());
|
actualIntent.putExtra(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), decryptedPushMessage.getId());
|
||||||
actualIntent.putExtra(BundleKeys.KEY_MESSAGE_ID, messageId);
|
actualIntent.putExtra(BundleKeys.KEY_MESSAGE_ID, messageId);
|
||||||
|
|
||||||
@ -593,22 +595,22 @@ public class NotificationWorker extends Worker {
|
|||||||
if (decryptedPushMessage.getDelete()) {
|
if (decryptedPushMessage.getDelete()) {
|
||||||
NotificationUtils.INSTANCE.cancelExistingNotificationWithId(
|
NotificationUtils.INSTANCE.cancelExistingNotificationWithId(
|
||||||
context,
|
context,
|
||||||
signatureVerification.getUserEntity(),
|
signatureVerification.getUser(),
|
||||||
decryptedPushMessage.getNotificationId());
|
decryptedPushMessage.getNotificationId());
|
||||||
} else if (decryptedPushMessage.getDeleteAll()) {
|
} else if (decryptedPushMessage.getDeleteAll()) {
|
||||||
NotificationUtils.INSTANCE.cancelAllNotificationsForAccount(
|
NotificationUtils.INSTANCE.cancelAllNotificationsForAccount(
|
||||||
context,
|
context,
|
||||||
signatureVerification.getUserEntity());
|
signatureVerification.getUser());
|
||||||
} else if (decryptedPushMessage.getDeleteMultiple()) {
|
} else if (decryptedPushMessage.getDeleteMultiple()) {
|
||||||
for (long notificationId : decryptedPushMessage.getNotificationIds()) {
|
for (long notificationId : decryptedPushMessage.getNotificationIds()) {
|
||||||
NotificationUtils.INSTANCE.cancelExistingNotificationWithId(
|
NotificationUtils.INSTANCE.cancelExistingNotificationWithId(
|
||||||
context,
|
context,
|
||||||
signatureVerification.getUserEntity(),
|
signatureVerification.getUser(),
|
||||||
notificationId);
|
notificationId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
credentials = ApiUtils.getCredentials(signatureVerification.getUserEntity().getUsername(),
|
credentials = ApiUtils.getCredentials(signatureVerification.getUser().getUsername(),
|
||||||
signatureVerification.getUserEntity().getToken());
|
signatureVerification.getUser().getToken());
|
||||||
|
|
||||||
ncApi = retrofit.newBuilder().client(okHttpClient.newBuilder().cookieJar(new
|
ncApi = retrofit.newBuilder().client(okHttpClient.newBuilder().cookieJar(new
|
||||||
JavaNetCookieJar(new CookieManager())).build()).build().create(NcApi.class);
|
JavaNetCookieJar(new CookieManager())).build()).build().create(NcApi.class);
|
||||||
@ -632,7 +634,7 @@ public class NotificationWorker extends Worker {
|
|||||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), decryptedPushMessage.getId());
|
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), decryptedPushMessage.getId());
|
||||||
|
|
||||||
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_USER_ENTITY(),
|
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_USER_ENTITY(),
|
||||||
signatureVerification.getUserEntity());
|
signatureVerification.getUser());
|
||||||
|
|
||||||
bundle.putBoolean(BundleKeys.INSTANCE.getKEY_FROM_NOTIFICATION_START_CALL(),
|
bundle.putBoolean(BundleKeys.INSTANCE.getKEY_FROM_NOTIFICATION_START_CALL(),
|
||||||
startACall);
|
startACall);
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
package com.nextcloud.talk.models
|
package com.nextcloud.talk.models
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import com.nextcloud.talk.models.database.UserEntity
|
import com.nextcloud.talk.data.user.model.User
|
||||||
import kotlinx.android.parcel.Parcelize
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class SignatureVerification(
|
data class SignatureVerification(
|
||||||
var signatureValid: Boolean = false,
|
var signatureValid: Boolean = false,
|
||||||
var userEntity: UserEntity? = null
|
var user: User? = null
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
@ -283,7 +283,8 @@ public class ChooseAccountDialogFragment extends DialogFragment {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
Boolean.TRUE,
|
Boolean.TRUE,
|
||||||
null, userEntity.getId(),
|
null,
|
||||||
|
userEntity.getId(),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null)
|
null)
|
||||||
|
@ -116,6 +116,14 @@ class UserManager internal constructor(private val userRepository: UsersReposito
|
|||||||
}.map { TRUE }
|
}.map { TRUE }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateExternalSignalingServer(id: Long, externalSignalingServer: ExternalSignalingServer): Single<Int> {
|
||||||
|
return userRepository.getUserWithId(id).map { user ->
|
||||||
|
user.externalSignalingServer = externalSignalingServer
|
||||||
|
userRepository.updateUser(user)
|
||||||
|
}.toSingle()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated("Only available for migration, use updateExternalSignalingServer or create new methods")
|
||||||
fun createOrUpdateUser(
|
fun createOrUpdateUser(
|
||||||
username: String?,
|
username: String?,
|
||||||
userAttributes: UserAttributes,
|
userAttributes: UserAttributes,
|
||||||
|
@ -121,7 +121,12 @@ public class ApiUtils {
|
|||||||
return baseUrl + ocsApiVersion + "/cloud/capabilities";
|
return baseUrl + ocsApiVersion + "/cloud/capabilities";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static int getCallApiVersion(UserEntity capabilities, int[] versions) throws NoSupportedApiException {
|
public static int getCallApiVersion(UserEntity capabilities, int[] versions) throws NoSupportedApiException {
|
||||||
|
return getCallApiVersion(LegacyUserEntityMapper.toModel(capabilities), versions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getCallApiVersion(User capabilities, int[] versions) throws NoSupportedApiException {
|
||||||
return getConversationApiVersion(capabilities, versions);
|
return getConversationApiVersion(capabilities, versions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,20 +166,25 @@ public class ApiUtils {
|
|||||||
return getConversationApiVersion(LegacyUserEntityMapper.toModel(user), versions);
|
return getConversationApiVersion(LegacyUserEntityMapper.toModel(user), versions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static int getSignalingApiVersion(UserEntity user, int[] versions) throws NoSupportedApiException {
|
public static int getSignalingApiVersion(UserEntity user, int[] versions) throws NoSupportedApiException {
|
||||||
|
return getSignalingApiVersion(LegacyUserEntityMapper.toModel(user), versions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getSignalingApiVersion(User user, int[] versions) throws NoSupportedApiException {
|
||||||
for (int version : versions) {
|
for (int version : versions) {
|
||||||
if (CapabilitiesUtil.hasSpreedFeatureCapability(user, "signaling-v" + version)) {
|
if (CapabilitiesUtilNew.hasSpreedFeatureCapability(user, "signaling-v" + version)) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version == APIv2 &&
|
if (version == APIv2 &&
|
||||||
CapabilitiesUtil.hasSpreedFeatureCapability(user, "sip-support") &&
|
CapabilitiesUtilNew.hasSpreedFeatureCapability(user, "sip-support") &&
|
||||||
!CapabilitiesUtil.hasSpreedFeatureCapability(user, "signaling-v3")) {
|
!CapabilitiesUtilNew.hasSpreedFeatureCapability(user, "signaling-v3")) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version == APIv1 &&
|
if (version == APIv1 &&
|
||||||
!CapabilitiesUtil.hasSpreedFeatureCapability(user, "signaling-v3")) {
|
!CapabilitiesUtilNew.hasSpreedFeatureCapability(user, "signaling-v3")) {
|
||||||
// Has no capability, we just assume it is always there when there is no v3 or later
|
// Has no capability, we just assume it is always there when there is no v3 or later
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ import com.nextcloud.talk.BuildConfig
|
|||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.data.user.model.User
|
import com.nextcloud.talk.data.user.model.User
|
||||||
import com.nextcloud.talk.models.RingtoneSettings
|
import com.nextcloud.talk.models.RingtoneSettings
|
||||||
import com.nextcloud.talk.models.database.UserEntity
|
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@ -218,20 +217,14 @@ object NotificationUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cancelAllNotificationsForAccount(context: Context?, conversationUser: UserEntity) {
|
fun cancelAllNotificationsForAccount(context: Context?, conversationUser: User) {
|
||||||
scanNotifications(
|
scanNotifications(context, conversationUser) { notificationManager, statusBarNotification, _ ->
|
||||||
context,
|
|
||||||
LegacyUserEntityMapper.toModel(conversationUser)!!
|
|
||||||
) { notificationManager, statusBarNotification, _ ->
|
|
||||||
notificationManager.cancel(statusBarNotification.id)
|
notificationManager.cancel(statusBarNotification.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cancelExistingNotificationWithId(context: Context?, conversationUser: UserEntity, notificationId: Long?) {
|
fun cancelExistingNotificationWithId(context: Context?, conversationUser: User, notificationId: Long?) {
|
||||||
scanNotifications(
|
scanNotifications(context, conversationUser) { notificationManager, statusBarNotification, notification ->
|
||||||
context,
|
|
||||||
LegacyUserEntityMapper.toModel(conversationUser)!!
|
|
||||||
) { notificationManager, statusBarNotification, notification ->
|
|
||||||
if (notificationId == notification.extras.getLong(BundleKeys.KEY_NOTIFICATION_ID)) {
|
if (notificationId == notification.extras.getLong(BundleKeys.KEY_NOTIFICATION_ID)) {
|
||||||
notificationManager.cancel(statusBarNotification.id)
|
notificationManager.cancel(statusBarNotification.id)
|
||||||
}
|
}
|
||||||
@ -240,13 +233,10 @@ object NotificationUtils {
|
|||||||
|
|
||||||
fun findNotificationForRoom(
|
fun findNotificationForRoom(
|
||||||
context: Context?,
|
context: Context?,
|
||||||
conversationUser: UserEntity,
|
conversationUser: User,
|
||||||
roomTokenOrId: String
|
roomTokenOrId: String
|
||||||
): StatusBarNotification? {
|
): StatusBarNotification? {
|
||||||
scanNotifications(
|
scanNotifications(context, conversationUser) { _, statusBarNotification, notification ->
|
||||||
context,
|
|
||||||
LegacyUserEntityMapper.toModel(conversationUser)!!
|
|
||||||
) { _, statusBarNotification, notification ->
|
|
||||||
if (roomTokenOrId == notification.extras.getString(BundleKeys.KEY_ROOM_TOKEN)) {
|
if (roomTokenOrId == notification.extras.getString(BundleKeys.KEY_ROOM_TOKEN)) {
|
||||||
return statusBarNotification
|
return statusBarNotification
|
||||||
}
|
}
|
||||||
@ -254,11 +244,7 @@ object NotificationUtils {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cancelExistingNotificationsForRoom(
|
fun cancelExistingNotificationsForRoom(context: Context?, conversationUser: User, roomTokenOrId: String) {
|
||||||
context: Context?,
|
|
||||||
conversationUser: User,
|
|
||||||
roomTokenOrId: String
|
|
||||||
) {
|
|
||||||
scanNotifications(context, conversationUser) { notificationManager, statusBarNotification, notification ->
|
scanNotifications(context, conversationUser) { notificationManager, statusBarNotification, notification ->
|
||||||
if (roomTokenOrId == notification.extras.getString(BundleKeys.KEY_ROOM_TOKEN)) {
|
if (roomTokenOrId == notification.extras.getString(BundleKeys.KEY_ROOM_TOKEN)) {
|
||||||
notificationManager.cancel(statusBarNotification.id)
|
notificationManager.cancel(statusBarNotification.id)
|
||||||
|
@ -31,11 +31,13 @@ import com.bluelinelabs.logansquare.LoganSquare;
|
|||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
import com.nextcloud.talk.api.NcApi;
|
import com.nextcloud.talk.api.NcApi;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
|
import com.nextcloud.talk.data.user.model.User;
|
||||||
import com.nextcloud.talk.events.EventStatus;
|
import com.nextcloud.talk.events.EventStatus;
|
||||||
import com.nextcloud.talk.models.SignatureVerification;
|
import com.nextcloud.talk.models.SignatureVerification;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
import com.nextcloud.talk.models.database.UserEntity;
|
||||||
import com.nextcloud.talk.models.json.push.PushConfigurationState;
|
import com.nextcloud.talk.models.json.push.PushConfigurationState;
|
||||||
import com.nextcloud.talk.models.json.push.PushRegistrationOverall;
|
import com.nextcloud.talk.models.json.push.PushRegistrationOverall;
|
||||||
|
import com.nextcloud.talk.users.UserManager;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
||||||
|
|
||||||
@ -78,6 +80,9 @@ public class PushUtils {
|
|||||||
@Inject
|
@Inject
|
||||||
UserUtils userUtils;
|
UserUtils userUtils;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
UserManager userManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AppPreferences appPreferences;
|
AppPreferences appPreferences;
|
||||||
|
|
||||||
@ -103,27 +108,23 @@ public class PushUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SignatureVerification verifySignature(byte[] signatureBytes, byte[] subjectBytes) {
|
public SignatureVerification verifySignature(byte[] signatureBytes, byte[] subjectBytes) {
|
||||||
Signature signature = null;
|
|
||||||
PushConfigurationState pushConfigurationState;
|
|
||||||
PublicKey publicKey;
|
|
||||||
SignatureVerification signatureVerification = new SignatureVerification();
|
SignatureVerification signatureVerification = new SignatureVerification();
|
||||||
signatureVerification.setSignatureValid(false);
|
signatureVerification.setSignatureValid(false);
|
||||||
|
|
||||||
List<UserEntity> userEntities = userUtils.getUsers();
|
List<User> users = userManager.getUsers().blockingGet();
|
||||||
try {
|
try {
|
||||||
signature = Signature.getInstance("SHA512withRSA");
|
Signature signature = Signature.getInstance("SHA512withRSA");
|
||||||
if (userEntities != null && userEntities.size() > 0) {
|
if (users != null && users.size() > 0) {
|
||||||
for (UserEntity userEntity : userEntities) {
|
PublicKey publicKey;
|
||||||
if (!TextUtils.isEmpty(userEntity.getPushConfigurationState())) {
|
for (User user : users) {
|
||||||
pushConfigurationState = LoganSquare.parse(userEntity.getPushConfigurationState(),
|
if (user.getPushConfigurationState() != null) {
|
||||||
PushConfigurationState.class);
|
|
||||||
publicKey = (PublicKey) readKeyFromString(true,
|
publicKey = (PublicKey) readKeyFromString(true,
|
||||||
pushConfigurationState.getUserPublicKey());
|
user.getPushConfigurationState().getUserPublicKey());
|
||||||
signature.initVerify(publicKey);
|
signature.initVerify(publicKey);
|
||||||
signature.update(subjectBytes);
|
signature.update(subjectBytes);
|
||||||
if (signature.verify(signatureBytes)) {
|
if (signature.verify(signatureBytes)) {
|
||||||
signatureVerification.setSignatureValid(true);
|
signatureVerification.setSignatureValid(true);
|
||||||
signatureVerification.setUserEntity(userEntity);
|
signatureVerification.setUser(user);
|
||||||
return signatureVerification;
|
return signatureVerification;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,8 +132,6 @@ public class PushUtils {
|
|||||||
}
|
}
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
Log.d(TAG, "No such algorithm");
|
Log.d(TAG, "No such algorithm");
|
||||||
} catch (IOException e) {
|
|
||||||
Log.d(TAG, "Error while trying to parse push configuration state");
|
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
Log.d(TAG, "Invalid key while trying to verify");
|
Log.d(TAG, "Invalid key while trying to verify");
|
||||||
} catch (SignatureException e) {
|
} catch (SignatureException e) {
|
||||||
|
@ -27,9 +27,9 @@ import android.util.Log;
|
|||||||
import com.bluelinelabs.logansquare.LoganSquare;
|
import com.bluelinelabs.logansquare.LoganSquare;
|
||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
|
import com.nextcloud.talk.data.user.model.User;
|
||||||
import com.nextcloud.talk.events.NetworkEvent;
|
import com.nextcloud.talk.events.NetworkEvent;
|
||||||
import com.nextcloud.talk.events.WebSocketCommunicationEvent;
|
import com.nextcloud.talk.events.WebSocketCommunicationEvent;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
|
||||||
import com.nextcloud.talk.models.json.participants.Participant;
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
|
import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
||||||
@ -90,7 +90,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
@Inject
|
@Inject
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
private UserEntity conversationUser;
|
private User conversationUser;
|
||||||
private String webSocketTicket;
|
private String webSocketTicket;
|
||||||
private String resumeId;
|
private String resumeId;
|
||||||
private String sessionId;
|
private String sessionId;
|
||||||
@ -109,7 +109,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
|
|
||||||
private List<String> messagesQueue = new ArrayList<>();
|
private List<String> messagesQueue = new ArrayList<>();
|
||||||
|
|
||||||
MagicWebSocketInstance(UserEntity conversationUser, String connectionUrl, String webSocketTicket) {
|
MagicWebSocketInstance(User conversationUser, String connectionUrl, String webSocketTicket) {
|
||||||
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
|
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
|
||||||
|
|
||||||
this.connectionUrl = connectionUrl;
|
this.connectionUrl = connectionUrl;
|
||||||
|
@ -24,6 +24,7 @@ import android.annotation.SuppressLint;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
|
import com.nextcloud.talk.data.user.model.User;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
import com.nextcloud.talk.models.database.UserEntity;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
|
import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
|
||||||
import com.nextcloud.talk.models.json.websocket.ActorWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.ActorWebSocketMessage;
|
||||||
@ -39,6 +40,7 @@ import com.nextcloud.talk.models.json.websocket.RoomOverallWebSocketMessage;
|
|||||||
import com.nextcloud.talk.models.json.websocket.RoomWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.RoomWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.SignalingDataWebSocketMessageForOffer;
|
import com.nextcloud.talk.models.json.websocket.SignalingDataWebSocketMessageForOffer;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
|
import com.nextcloud.talk.utils.LegacyUserEntityMapper;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -70,7 +72,19 @@ public class WebSocketConnectionHelper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized MagicWebSocketInstance getExternalSignalingInstanceForServer(String url, UserEntity userEntity, String webSocketTicket, boolean isGuest) {
|
@Deprecated
|
||||||
|
public static synchronized MagicWebSocketInstance getExternalSignalingInstanceForServer(String url,
|
||||||
|
UserEntity userEntity,
|
||||||
|
String webSocketTicket, boolean isGuest) {
|
||||||
|
return getExternalSignalingInstanceForServer(url,
|
||||||
|
LegacyUserEntityMapper.toModel(userEntity),
|
||||||
|
webSocketTicket,
|
||||||
|
isGuest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized MagicWebSocketInstance getExternalSignalingInstanceForServer(String url,
|
||||||
|
User user,
|
||||||
|
String webSocketTicket, boolean isGuest) {
|
||||||
String generatedURL = url.replace("https://", "wss://").replace("http://", "ws://");
|
String generatedURL = url.replace("https://", "wss://").replace("http://", "ws://");
|
||||||
|
|
||||||
if (generatedURL.endsWith("/")) {
|
if (generatedURL.endsWith("/")) {
|
||||||
@ -79,18 +93,17 @@ public class WebSocketConnectionHelper {
|
|||||||
generatedURL += "/spreed";
|
generatedURL += "/spreed";
|
||||||
}
|
}
|
||||||
|
|
||||||
long userId = isGuest ? -1 : userEntity.getId();
|
long userId = isGuest ? -1 : user.getId();
|
||||||
|
|
||||||
|
|
||||||
MagicWebSocketInstance magicWebSocketInstance;
|
MagicWebSocketInstance magicWebSocketInstance;
|
||||||
if (userId != -1 && magicWebSocketInstanceMap.containsKey(userEntity.getId()) && (magicWebSocketInstance = magicWebSocketInstanceMap.get(userEntity.getId())) != null) {
|
if (userId != -1 && magicWebSocketInstanceMap.containsKey(user.getId()) && (magicWebSocketInstance = magicWebSocketInstanceMap.get(user.getId())) != null) {
|
||||||
return magicWebSocketInstance;
|
return magicWebSocketInstance;
|
||||||
} else {
|
} else {
|
||||||
if (userId == -1) {
|
if (userId == -1) {
|
||||||
deleteExternalSignalingInstanceForUserEntity(userId);
|
deleteExternalSignalingInstanceForUserEntity(userId);
|
||||||
}
|
}
|
||||||
magicWebSocketInstance = new MagicWebSocketInstance(userEntity, generatedURL, webSocketTicket);
|
magicWebSocketInstance = new MagicWebSocketInstance(user, generatedURL, webSocketTicket);
|
||||||
magicWebSocketInstanceMap.put(userEntity.getId(), magicWebSocketInstance);
|
magicWebSocketInstanceMap.put(user.getId(), magicWebSocketInstance);
|
||||||
return magicWebSocketInstance;
|
return magicWebSocketInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,19 +118,19 @@ public class WebSocketConnectionHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HelloOverallWebSocketMessage getAssembledHelloModel(UserEntity userEntity, String ticket) {
|
HelloOverallWebSocketMessage getAssembledHelloModel(User user, String ticket) {
|
||||||
int apiVersion = ApiUtils.getSignalingApiVersion(userEntity, new int[] {ApiUtils.APIv3, 2, 1});
|
int apiVersion = ApiUtils.getSignalingApiVersion(user, new int[] {ApiUtils.APIv3, 2, 1});
|
||||||
|
|
||||||
HelloOverallWebSocketMessage helloOverallWebSocketMessage = new HelloOverallWebSocketMessage();
|
HelloOverallWebSocketMessage helloOverallWebSocketMessage = new HelloOverallWebSocketMessage();
|
||||||
helloOverallWebSocketMessage.setType("hello");
|
helloOverallWebSocketMessage.setType("hello");
|
||||||
HelloWebSocketMessage helloWebSocketMessage = new HelloWebSocketMessage();
|
HelloWebSocketMessage helloWebSocketMessage = new HelloWebSocketMessage();
|
||||||
helloWebSocketMessage.setVersion("1.0");
|
helloWebSocketMessage.setVersion("1.0");
|
||||||
AuthWebSocketMessage authWebSocketMessage = new AuthWebSocketMessage();
|
AuthWebSocketMessage authWebSocketMessage = new AuthWebSocketMessage();
|
||||||
authWebSocketMessage.setUrl(ApiUtils.getUrlForSignalingBackend(apiVersion, userEntity.getBaseUrl()));
|
authWebSocketMessage.setUrl(ApiUtils.getUrlForSignalingBackend(apiVersion, user.getBaseUrl()));
|
||||||
AuthParametersWebSocketMessage authParametersWebSocketMessage = new AuthParametersWebSocketMessage();
|
AuthParametersWebSocketMessage authParametersWebSocketMessage = new AuthParametersWebSocketMessage();
|
||||||
authParametersWebSocketMessage.setTicket(ticket);
|
authParametersWebSocketMessage.setTicket(ticket);
|
||||||
if (!userEntity.getUserId().equals("?")) {
|
if (!("?").equals(user.getUserId())) {
|
||||||
authParametersWebSocketMessage.setUserid(userEntity.getUserId());
|
authParametersWebSocketMessage.setUserid(user.getUserId());
|
||||||
}
|
}
|
||||||
authWebSocketMessage.setAuthParametersWebSocketMessage(authParametersWebSocketMessage);
|
authWebSocketMessage.setAuthParametersWebSocketMessage(authParametersWebSocketMessage);
|
||||||
helloWebSocketMessage.setAuthWebSocketMessage(authWebSocketMessage);
|
helloWebSocketMessage.setAuthWebSocketMessage(authWebSocketMessage);
|
||||||
|
@ -1 +1 @@
|
|||||||
154
|
152
|
Loading…
Reference in New Issue
Block a user