Skip to content

Commit

Permalink
feat: Join public room for notification #2813
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Sep 3, 2024
1 parent c69d17c commit 27ee7a6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/chat_room/cubit/chat_room_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ abstract class ChatRoomCubit extends Cubit<ChatRoomState> {
helpCenterOptions.customNotification != null &&
helpCenterOptions.customNotification! &&
helpCenterOptions.customNotificationRoom != null) {
invites.add(helpCenterOptions.customNotificationRoom!);
_roomId = await matrixChat
.joinRoom(helpCenterOptions.customNotificationRoom!);
}
} else {
//roomIdStoredKey == SecureStorageKeys.chatSupportRoomId
Expand All @@ -303,13 +304,12 @@ abstract class ChatRoomCubit extends Cubit<ChatRoomState> {
} else {
invites.add(AltMeStrings.matrixChatSupportId);
}
_roomId = await matrixChat.createRoomAndInviteSupport(
tokenParameters.thumbprint,
invites,
);
}

_roomId = await matrixChat.createRoomAndInviteSupport(
tokenParameters.thumbprint,
invites,
);

await matrixChat.setRoomIdInStorage(roomIdStoredKey, _roomId!);
_getUnreadMessageCount();
await _subscribeToEventsOfRoom();
Expand Down
16 changes: 16 additions & 0 deletions lib/chat_room/matrix_chat/matrix_chat_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,22 @@ class MatrixChatImpl extends MatrixChatInterface {
}
}

/// join room with [roomName]
@override
Future<String> joinRoom(String roomName) async {
try {
if (client == null) {
await _initClient();
}
final roomId = await client!.joinRoom(roomName);
await enableRoomEncyption(roomId);
return roomId;
} catch (e, s) {
logger.e('e: $e, s: $s');
throw Exception();
}
}

@override
String getThumbnail({
required String url,
Expand Down
1 change: 1 addition & 0 deletions lib/chat_room/matrix_chat/matrix_chat_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ abstract class MatrixChatInterface {
String roomName,
List<String>? invites,
);
Future<String> joinRoom(String roomName);
Future<void> enableRoomEncyption(String roomId);
Future<void> handleImageSelection({
required OnMessageCreated onMessageCreated,
Expand Down
10 changes: 10 additions & 0 deletions lib/enterprise/cubit/enterprise_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,16 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {
// );
// }

final helpCenterOptions = profileSetting.helpCenterOptions;

if (helpCenterOptions.displayNotification != null &&
helpCenterOptions.displayNotification! &&
helpCenterOptions.customNotification != null &&
helpCenterOptions.customNotification! &&
helpCenterOptions.customNotificationRoom != null) {
await matrixNotificationCubit.init();
}

emit(
state.copyWith(
status: AppStatus.success,
Expand Down

0 comments on commit 27ee7a6

Please sign in to comment.