Complete the realm system

This commit is contained in:
2024-05-06 23:30:30 +08:00
parent 22c2a80650
commit ae4d9cf81a
6 changed files with 100 additions and 12 deletions

View File

@ -44,14 +44,13 @@ class ChatProvider extends ChangeNotifier {
return channel;
}
Future<Channel> fetchChannel(String alias, String realm) async {
final Client client = Client();
var uri = getRequestUri('messaging', '/api/channels/$realm/$alias');
var res = await client.get(uri);
if (res.statusCode == 200) {
Future<Channel> fetchChannel(AuthProvider auth, String alias, String realm) async {
var uri = getRequestUri('messaging', '/api/channels/$realm/$alias/availability');
var res = await auth.client!.get(uri);
if (res.statusCode == 200 || res.statusCode == 403) {
final result = jsonDecode(utf8.decode(res.bodyBytes));
focusChannel = Channel.fromJson(result);
focusChannel?.isAvailable = res.statusCode == 200;
notifyListeners();
return focusChannel!;
} else {