diff --git a/lib/models/channel.dart b/lib/models/channel.dart index a783551..b3df743 100644 --- a/lib/models/channel.dart +++ b/lib/models/channel.dart @@ -13,7 +13,7 @@ class Channel { int type; Account account; int accountId; - int realmId; + int? realmId; Channel({ required this.id, @@ -28,7 +28,7 @@ class Channel { required this.type, required this.account, required this.accountId, - required this.realmId, + this.realmId, }); factory Channel.fromJson(Map json) => Channel( diff --git a/lib/providers/chat.dart b/lib/providers/chat.dart index 091cd74..bb50e43 100644 --- a/lib/providers/chat.dart +++ b/lib/providers/chat.dart @@ -47,7 +47,7 @@ class ChatProvider extends ChangeNotifier { Future fetchChannel(String alias) async { final Client client = Client(); - var uri = getRequestUri('messaging', '/api/channels/$alias'); + var uri = getRequestUri('messaging', '/api/channels/global/$alias'); var res = await client.get(uri); if (res.statusCode == 200) { final result = jsonDecode(utf8.decode(res.bodyBytes)); @@ -63,7 +63,7 @@ class ChatProvider extends ChangeNotifier { Future fetchOngoingCall(String alias) async { final Client client = Client(); - var uri = getRequestUri('messaging', '/api/channels/$alias/calls/ongoing'); + var uri = getRequestUri('messaging', '/api/channels/global/$alias/calls/ongoing'); var res = await client.get(uri); if (res.statusCode == 200) { final result = jsonDecode(utf8.decode(res.bodyBytes)); @@ -181,7 +181,7 @@ class ChatCallInstance { throw Exception('unauthorized'); } - var uri = getRequestUri('messaging', '/api/channels/${channel.alias}/calls/ongoing/token'); + var uri = getRequestUri('messaging', '/api/channels/global/${channel.alias}/calls/ongoing/token'); var res = await auth.client!.post(uri); if (res.statusCode == 200) { diff --git a/lib/screens/chat/channel/channel_editor.dart b/lib/screens/chat/channel/channel_editor.dart index 9b8b508..9675196 100644 --- a/lib/screens/chat/channel/channel_editor.dart +++ b/lib/screens/chat/channel/channel_editor.dart @@ -39,8 +39,8 @@ class _ChannelEditorScreenState extends State { } final uri = widget.editing == null - ? getRequestUri('messaging', '/api/channels') - : getRequestUri('messaging', '/api/channels/${widget.editing!.id}'); + ? getRequestUri('messaging', '/api/channels/global') + : getRequestUri('messaging', '/api/channels/global/${widget.editing!.id}'); final req = Request(widget.editing == null ? 'POST' : 'PUT', uri); req.headers['Content-Type'] = 'application/json'; diff --git a/lib/screens/chat/channel/channel_member.dart b/lib/screens/chat/channel/channel_member.dart index 66a12f6..210b491 100644 --- a/lib/screens/chat/channel/channel_member.dart +++ b/lib/screens/chat/channel/channel_member.dart @@ -37,7 +37,7 @@ class _ChatMemberScreenState extends State { _selfId = prof['id']; var uri = getRequestUri( - 'messaging', '/api/channels/${widget.channel.alias}/members'); + 'messaging', '/api/channels/global/${widget.channel.alias}/members'); var res = await auth.client!.get(uri); if (res.statusCode == 200) { @@ -61,7 +61,7 @@ class _ChatMemberScreenState extends State { } var uri = getRequestUri( - 'messaging', '/api/channels/${widget.channel.alias}/kick'); + 'messaging', '/api/channels/global/${widget.channel.alias}/kick'); var res = await auth.client!.post( uri, @@ -92,7 +92,7 @@ class _ChatMemberScreenState extends State { } var uri = getRequestUri( - 'messaging', '/api/channels/${widget.channel.alias}/invite'); + 'messaging', '/api/channels/global/${widget.channel.alias}/invite'); var res = await auth.client!.post( uri, diff --git a/lib/screens/chat/chat.dart b/lib/screens/chat/chat.dart index dd4fcef..d2fbc5d 100644 --- a/lib/screens/chat/chat.dart +++ b/lib/screens/chat/chat.dart @@ -77,7 +77,7 @@ class _ChatScreenWidgetState extends State { var uri = getRequestUri( 'messaging', - '/api/channels/${widget.alias}/messages?take=$take&offset=$offset', + '/api/channels/global/${widget.alias}/messages?take=$take&offset=$offset', ); var res = await auth.client!.get(uri); diff --git a/lib/screens/chat/chat_list.dart b/lib/screens/chat/chat_list.dart index 3277597..7aa686d 100644 --- a/lib/screens/chat/chat_list.dart +++ b/lib/screens/chat/chat_list.dart @@ -58,7 +58,7 @@ class _ChatListWidgetState extends State { final auth = context.read(); if (!await auth.isAuthorized()) return; - var uri = getRequestUri('messaging', '/api/channels/me/available'); + var uri = getRequestUri('messaging', '/api/channels/global/me/available'); var res = await auth.client!.get(uri); if (res.statusCode == 200) { diff --git a/lib/widgets/chat/channel_action.dart b/lib/widgets/chat/channel_action.dart index fd6e6e2..8c0537e 100644 --- a/lib/widgets/chat/channel_action.dart +++ b/lib/widgets/chat/channel_action.dart @@ -33,7 +33,7 @@ class _ChannelCallActionState extends State { return; } - var uri = getRequestUri('messaging', '/api/channels/${widget.channel.alias}/calls'); + var uri = getRequestUri('messaging', '/api/channels/global/${widget.channel.alias}/calls'); var res = await auth.client!.post(uri); if (res.statusCode != 200) { @@ -54,7 +54,7 @@ class _ChannelCallActionState extends State { return; } - var uri = getRequestUri('messaging', '/api/channels/${widget.channel.alias}/calls/ongoing'); + var uri = getRequestUri('messaging', '/api/channels/global/${widget.channel.alias}/calls/ongoing'); var res = await auth.client!.delete(uri); if (res.statusCode != 200) { diff --git a/lib/widgets/chat/channel_deletion.dart b/lib/widgets/chat/channel_deletion.dart index 6d5c206..3ac4452 100644 --- a/lib/widgets/chat/channel_deletion.dart +++ b/lib/widgets/chat/channel_deletion.dart @@ -32,7 +32,7 @@ class _ChannelDeletionState extends State { } var res = await auth.client!.delete( - getRequestUri('messaging', '/api/channels/${widget.channel.id}'), + getRequestUri('messaging', '/api/channels/global/${widget.channel.id}'), ); if (res.statusCode != 200) { var message = utf8.decode(res.bodyBytes); @@ -54,7 +54,7 @@ class _ChannelDeletionState extends State { } var res = await auth.client!.post( - getRequestUri('messaging', '/api/channels/${widget.channel.alias}/leave'), + getRequestUri('messaging', '/api/channels/global/${widget.channel.alias}/leave'), ); if (res.statusCode != 200) { var message = utf8.decode(res.bodyBytes); diff --git a/lib/widgets/chat/message_deletion.dart b/lib/widgets/chat/message_deletion.dart index cfba7ec..dc66954 100644 --- a/lib/widgets/chat/message_deletion.dart +++ b/lib/widgets/chat/message_deletion.dart @@ -31,7 +31,7 @@ class _ChatMessageDeletionDialogState extends State { if (!await auth.isAuthorized()) return; final uri = getRequestUri('messaging', - '/api/channels/${widget.channel}/messages/${widget.item.id}'); + '/api/channels/global/${widget.channel}/messages/${widget.item.id}'); setState(() => _isSubmitting = true); final res = await auth.client!.delete(uri); diff --git a/lib/widgets/chat/message_editor.dart b/lib/widgets/chat/message_editor.dart index c72e63c..9b852fe 100644 --- a/lib/widgets/chat/message_editor.dart +++ b/lib/widgets/chat/message_editor.dart @@ -53,8 +53,8 @@ class _ChatMessageEditorState extends State { if (!await auth.isAuthorized()) return; final uri = widget.editing == null - ? getRequestUri('messaging', '/api/channels/${widget.channel}/messages') - : getRequestUri('messaging', '/api/channels/${widget.channel}/messages/${widget.editing!.id}'); + ? getRequestUri('messaging', '/api/channels/global/${widget.channel}/messages') + : getRequestUri('messaging', '/api/channels/global/${widget.channel}/messages/${widget.editing!.id}'); final req = Request(widget.editing == null ? 'POST' : 'PUT', uri); req.headers['Content-Type'] = 'application/json';