diff --git a/lib/models/message.dart b/lib/models/message.dart index 476e76d..a090f05 100644 --- a/lib/models/message.dart +++ b/lib/models/message.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:solian/models/account.dart'; import 'package:solian/models/channel.dart'; import 'package:solian/models/post.dart'; @@ -7,9 +9,9 @@ class Message { DateTime createdAt; DateTime updatedAt; DateTime? deletedAt; - String content; + String rawContent; Map? metadata; - int type; + String type; List? attachments; Channel? channel; Sender sender; @@ -20,12 +22,16 @@ class Message { bool isSending = false; + Map get decodedContent { + return jsonDecode(utf8.fuse(base64).decode(rawContent)); + } + Message({ required this.id, required this.createdAt, required this.updatedAt, this.deletedAt, - required this.content, + required this.rawContent, required this.metadata, required this.type, this.attachments, @@ -42,18 +48,14 @@ class Message { createdAt: DateTime.parse(json['created_at']), updatedAt: DateTime.parse(json['updated_at']), deletedAt: json['deleted_at'], - content: json['content'], + rawContent: json['content'], metadata: json['metadata'], type: json['type'], - attachments: List.from( - json['attachments']?.map((x) => Attachment.fromJson(x)) ?? - List.empty()), + attachments: List.from(json['attachments']?.map((x) => Attachment.fromJson(x)) ?? List.empty()), channel: Channel.fromJson(json['channel']), sender: Sender.fromJson(json['sender']), replyId: json['reply_id'], - replyTo: json['reply_to'] != null - ? Message.fromJson(json['reply_to']) - : null, + replyTo: json['reply_to'] != null ? Message.fromJson(json['reply_to']) : null, channelId: json['channel_id'], senderId: json['sender_id'], ); @@ -63,11 +65,10 @@ class Message { 'created_at': createdAt.toIso8601String(), 'updated_at': updatedAt.toIso8601String(), 'deleted_at': deletedAt, - 'content': content, + 'content': rawContent, 'metadata': metadata, 'type': type, - 'attachments': List.from( - attachments?.map((x) => x.toJson()) ?? List.empty()), + 'attachments': List.from(attachments?.map((x) => x.toJson()) ?? List.empty()), 'channel': channel?.toJson(), 'sender': sender.toJson(), 'reply_id': replyId, diff --git a/lib/providers/auth.dart b/lib/providers/auth.dart index 8b9765c..8d367f3 100755 --- a/lib/providers/auth.dart +++ b/lib/providers/auth.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:oauth2/oauth2.dart' as oauth2; import 'package:solian/utils/http.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; class AuthProvider extends ChangeNotifier { AuthProvider() { diff --git a/lib/providers/chat.dart b/lib/providers/chat.dart index b95dae8..f565e29 100644 --- a/lib/providers/chat.dart +++ b/lib/providers/chat.dart @@ -13,7 +13,7 @@ import 'package:solian/models/message.dart'; import 'package:solian/models/packet.dart'; import 'package:solian/models/pagination.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/chat/call/exts.dart'; import 'package:solian/widgets/exts.dart'; import 'package:wakelock_plus/wakelock_plus.dart'; @@ -41,6 +41,7 @@ class ChatProvider extends ChangeNotifier { var uri = Uri( scheme: ori.scheme.replaceFirst('http', 'ws'), host: ori.host, + port: ori.port, path: ori.path, queryParameters: {'tk': Uri.encodeComponent(auth.client!.currentToken!)}, ); diff --git a/lib/providers/friend.dart b/lib/providers/friend.dart index 4cc0479..ec56c01 100644 --- a/lib/providers/friend.dart +++ b/lib/providers/friend.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:solian/models/friendship.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; class FriendProvider extends ChangeNotifier { List friends = List.empty(); diff --git a/lib/providers/notify.dart b/lib/providers/notify.dart index 3fea6a0..c8a0c57 100644 --- a/lib/providers/notify.dart +++ b/lib/providers/notify.dart @@ -6,7 +6,7 @@ import 'package:livekit_client/livekit_client.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:solian/models/pagination.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/models/notification.dart' as model; import 'package:web_socket_channel/web_socket_channel.dart'; import 'dart:math' as math; @@ -74,10 +74,11 @@ class NotifyProvider extends ChangeNotifier { await auth.client!.refreshToken(auth.client!.currentRefreshToken!); - var ori = getRequestUri('passport', '/api/notifications/listen'); + var ori = getRequestUri('passport', '/api/ws'); var uri = Uri( scheme: ori.scheme.replaceFirst('http', 'ws'), host: ori.host, + port: ori.port, path: ori.path, queryParameters: { 'tk': Uri.encodeComponent(auth.client!.currentToken!) diff --git a/lib/providers/realm.dart b/lib/providers/realm.dart index 37061ca..9b54737 100644 --- a/lib/providers/realm.dart +++ b/lib/providers/realm.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:solian/models/realm.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; class RealmProvider with ChangeNotifier { List realms = List.empty(); diff --git a/lib/screens/account/friend.dart b/lib/screens/account/friend.dart index 9d64cbe..63a8c9b 100644 --- a/lib/screens/account/friend.dart +++ b/lib/screens/account/friend.dart @@ -5,7 +5,7 @@ import 'package:flutter_animate/flutter_animate.dart'; import 'package:provider/provider.dart'; import 'package:solian/models/friendship.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/account/account_avatar.dart'; import 'package:solian/widgets/exts.dart'; import 'package:solian/widgets/scaffold.dart'; diff --git a/lib/screens/account/personalize.dart b/lib/screens/account/personalize.dart index c0fd578..cd6953b 100644 --- a/lib/screens/account/personalize.dart +++ b/lib/screens/account/personalize.dart @@ -8,7 +8,7 @@ import 'package:image_picker/image_picker.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/account/account_avatar.dart'; import 'package:solian/widgets/exts.dart'; import 'package:solian/widgets/scaffold.dart'; diff --git a/lib/screens/auth/signin.dart b/lib/screens/auth/signin.dart index bb7b755..5bf557a 100644 --- a/lib/screens/auth/signin.dart +++ b/lib/screens/auth/signin.dart @@ -3,7 +3,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/router.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/exts.dart'; import 'package:solian/widgets/scaffold.dart'; import 'package:url_launcher/url_launcher_string.dart'; diff --git a/lib/screens/auth/signup.dart b/lib/screens/auth/signup.dart index 142f831..884d547 100644 --- a/lib/screens/auth/signup.dart +++ b/lib/screens/auth/signup.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:solian/router.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/exts.dart'; import 'package:solian/widgets/scaffold.dart'; import 'package:http/http.dart' as http; diff --git a/lib/screens/chat/channel/channel_editor.dart b/lib/screens/chat/channel/channel_editor.dart index 1535541..95e1b3b 100644 --- a/lib/screens/chat/channel/channel_editor.dart +++ b/lib/screens/chat/channel/channel_editor.dart @@ -7,7 +7,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/channel.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/router.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/exts.dart'; import 'package:solian/widgets/scaffold.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; diff --git a/lib/screens/chat/channel/channel_member.dart b/lib/screens/chat/channel/channel_member.dart index 24df8e3..dc40368 100644 --- a/lib/screens/chat/channel/channel_member.dart +++ b/lib/screens/chat/channel/channel_member.dart @@ -6,7 +6,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/account.dart'; import 'package:solian/models/channel.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/account/account_avatar.dart'; import 'package:solian/widgets/account/friend_picker.dart'; import 'package:solian/widgets/exts.dart'; diff --git a/lib/screens/chat/chat.dart b/lib/screens/chat/chat.dart index 3905cba..954b4fe 100644 --- a/lib/screens/chat/chat.dart +++ b/lib/screens/chat/chat.dart @@ -8,7 +8,7 @@ import 'package:solian/models/message.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/providers/chat.dart'; import 'package:solian/router.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/utils/theme.dart'; import 'package:solian/widgets/chat/channel_action.dart'; import 'package:solian/widgets/chat/message.dart'; diff --git a/lib/screens/chat/chat_list.dart b/lib/screens/chat/chat_list.dart index e4be153..e6fbf89 100644 --- a/lib/screens/chat/chat_list.dart +++ b/lib/screens/chat/chat_list.dart @@ -6,7 +6,7 @@ import 'package:solian/models/channel.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/providers/chat.dart'; import 'package:solian/router.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/utils/theme.dart'; import 'package:solian/widgets/chat/chat_new.dart'; import 'package:solian/widgets/exts.dart'; diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index 43a9b09..5383c84 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -7,7 +7,7 @@ import 'package:solian/models/post.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/providers/realm.dart'; import 'package:solian/router.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:http/http.dart' as http; diff --git a/lib/screens/notification.dart b/lib/screens/notification.dart index eb49f4d..bde9628 100644 --- a/lib/screens/notification.dart +++ b/lib/screens/notification.dart @@ -5,7 +5,7 @@ import 'package:flutter_animate/flutter_animate.dart'; import 'package:provider/provider.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/providers/notify.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/scaffold.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:url_launcher/url_launcher_string.dart'; diff --git a/lib/screens/posts/comment_editor.dart b/lib/screens/posts/comment_editor.dart index 8fe7567..b6103a9 100644 --- a/lib/screens/posts/comment_editor.dart +++ b/lib/screens/posts/comment_editor.dart @@ -7,7 +7,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/post.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/router.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:solian/widgets/account/account_avatar.dart'; import 'package:solian/widgets/exts.dart'; diff --git a/lib/screens/posts/moment_editor.dart b/lib/screens/posts/moment_editor.dart index 66cc28f..b5cd220 100644 --- a/lib/screens/posts/moment_editor.dart +++ b/lib/screens/posts/moment_editor.dart @@ -7,7 +7,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/post.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/router.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:solian/widgets/account/account_avatar.dart'; import 'package:solian/widgets/exts.dart'; @@ -55,7 +55,6 @@ class _MomentEditorScreenState extends State { final uri = widget.editing == null ? getRequestUri('interactive', '/api/p/moments') : getRequestUri('interactive', '/api/p/moments/${widget.editing!.id}'); - print(uri); final req = Request(widget.editing == null ? 'POST' : 'PUT', uri); req.headers['Content-Type'] = 'application/json'; diff --git a/lib/screens/posts/screen.dart b/lib/screens/posts/screen.dart index 4437e9b..ca442f5 100644 --- a/lib/screens/posts/screen.dart +++ b/lib/screens/posts/screen.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:solian/models/post.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/exts.dart'; import 'package:solian/widgets/scaffold.dart'; import 'package:solian/widgets/posts/comment_list.dart'; diff --git a/lib/screens/realms/realm_editor.dart b/lib/screens/realms/realm_editor.dart index 0bbf79c..248403a 100644 --- a/lib/screens/realms/realm_editor.dart +++ b/lib/screens/realms/realm_editor.dart @@ -7,7 +7,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/realm.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/router.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/utils/theme.dart'; import 'package:solian/widgets/exts.dart'; import 'package:solian/widgets/scaffold.dart'; diff --git a/lib/screens/realms/realm_member.dart b/lib/screens/realms/realm_member.dart index 3c6fee5..f325c22 100644 --- a/lib/screens/realms/realm_member.dart +++ b/lib/screens/realms/realm_member.dart @@ -6,7 +6,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/account.dart'; import 'package:solian/models/realm.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/utils/theme.dart'; import 'package:solian/widgets/account/account_avatar.dart'; import 'package:solian/widgets/account/friend_picker.dart'; diff --git a/lib/screens/users/userinfo.dart b/lib/screens/users/userinfo.dart index e38053f..93ceee1 100644 --- a/lib/screens/users/userinfo.dart +++ b/lib/screens/users/userinfo.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart'; import 'package:solian/models/account.dart'; import 'package:solian/models/personal_page.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/utils/theme.dart'; import 'package:solian/widgets/account/account_avatar.dart'; import 'package:solian/widgets/account/personal_page_content.dart'; diff --git a/lib/utils/http.dart b/lib/utils/http.dart index 3907fb7..87e58d8 100644 --- a/lib/utils/http.dart +++ b/lib/utils/http.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; class HttpClient extends http.BaseClient { final bool isUnauthorizedRetry; diff --git a/lib/utils/service_url.dart b/lib/utils/services_url.dart similarity index 76% rename from lib/utils/service_url.dart rename to lib/utils/services_url.dart index 6951e90..da9159c 100644 --- a/lib/utils/service_url.dart +++ b/lib/utils/services_url.dart @@ -1,7 +1,7 @@ const serviceUrls = { 'passport': 'https://id.solsynth.dev', 'interactive': 'https://co.solsynth.dev', - 'messaging': 'https://im.solsynth.dev' + 'messaging': 'http://192.168.50.83:8447' // 'https://im.solsynth.dev' }; Uri getRequestUri(String service, String path) { diff --git a/lib/widgets/account/account_avatar.dart b/lib/widgets/account/account_avatar.dart index 217ba1d..1590326 100644 --- a/lib/widgets/account/account_avatar.dart +++ b/lib/widgets/account/account_avatar.dart @@ -1,7 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:solian/utils/platform.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; class AccountAvatar extends StatelessWidget { final String source; diff --git a/lib/widgets/chat/channel_action.dart b/lib/widgets/chat/channel_action.dart index 07a4513..1bb7765 100644 --- a/lib/widgets/chat/channel_action.dart +++ b/lib/widgets/chat/channel_action.dart @@ -7,7 +7,7 @@ import 'package:solian/models/channel.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/providers/chat.dart'; import 'package:solian/router.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/exts.dart'; class ChannelCallAction extends StatefulWidget { diff --git a/lib/widgets/chat/channel_deletion.dart b/lib/widgets/chat/channel_deletion.dart index 1173ad8..f75e6cd 100644 --- a/lib/widgets/chat/channel_deletion.dart +++ b/lib/widgets/chat/channel_deletion.dart @@ -5,7 +5,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/channel.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/exts.dart'; class ChannelDeletion extends StatefulWidget { diff --git a/lib/widgets/chat/message_content.dart b/lib/widgets/chat/message_content.dart index c78d380..101bd06 100644 --- a/lib/widgets/chat/message_content.dart +++ b/lib/widgets/chat/message_content.dart @@ -10,19 +10,23 @@ class ChatMessageContent extends StatelessWidget { @override Widget build(BuildContext context) { - return Markdown( - data: item.content, - shrinkWrap: true, - selectable: true, - physics: const NeverScrollableScrollPhysics(), - padding: const EdgeInsets.all(0), - onTapLink: (text, href, title) async { - if (href == null) return; - await launchUrlString( - href, - mode: LaunchMode.externalApplication, - ); - }, - ); + if (item.type == 'm.text') { + return Markdown( + data: item.decodedContent['value'], + shrinkWrap: true, + selectable: true, + physics: const NeverScrollableScrollPhysics(), + padding: const EdgeInsets.all(0), + onTapLink: (text, href, title) async { + if (href == null) return; + await launchUrlString( + href, + mode: LaunchMode.externalApplication, + ); + }, + ); + } + + return Container(); } } diff --git a/lib/widgets/chat/message_deletion.dart b/lib/widgets/chat/message_deletion.dart index a6e28ab..ba5f759 100644 --- a/lib/widgets/chat/message_deletion.dart +++ b/lib/widgets/chat/message_deletion.dart @@ -5,7 +5,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/message.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/exts.dart'; class ChatMessageDeletionDialog extends StatefulWidget { diff --git a/lib/widgets/chat/message_editor.dart b/lib/widgets/chat/message_editor.dart index b1e5390..3f62faf 100644 --- a/lib/widgets/chat/message_editor.dart +++ b/lib/widgets/chat/message_editor.dart @@ -9,7 +9,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/message.dart'; import 'package:solian/models/post.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/exts.dart'; import 'package:solian/widgets/posts/attachment_editor.dart'; import 'package:badges/badges.dart' as badge; @@ -55,6 +55,10 @@ class _ChatMessageEditorState extends State { ); } + Map buildContentBody(String content, {String algorithm = 'plain'}) { + return {'value': content, 'algorithm': algorithm}; + } + Future sendMessage(BuildContext context) async { _focusNode.requestFocus(); @@ -68,7 +72,8 @@ class _ChatMessageEditorState extends State { final req = Request(widget.editing == null ? 'POST' : 'PUT', uri); req.headers['Content-Type'] = 'application/json'; req.body = jsonEncode({ - 'content': _textController.value.text, + 'type': 'm.text', + 'content': buildContentBody(_textController.value.text), 'attachments': _attachments, 'reply_to': widget.replying?.id, }); @@ -106,7 +111,10 @@ class _ChatMessageEditorState extends State { setState(() { _prevEditingId = widget.editing!.id; _attachments = widget.editing!.attachments ?? List.empty(growable: true); - _textController.text = widget.editing!.content; + + if (widget.editing!.type == 'm.text') { + _textController.text = widget.editing!.decodedContent['value']; + } }); } } diff --git a/lib/widgets/notification_notifier.dart b/lib/widgets/notification_notifier.dart index 6f33452..7cbbcf8 100644 --- a/lib/widgets/notification_notifier.dart +++ b/lib/widgets/notification_notifier.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:solian/models/packet.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/providers/notify.dart'; import 'package:solian/router.dart'; @@ -35,9 +36,13 @@ class _NotificationNotifierState extends State { nty.connect(auth).then((snapshot) { snapshot!.stream.listen( (event) { - final result = model.Notification.fromJson(jsonDecode(event)); - nty.onRemoteMessage(result); - nty.notifyMessage(result.subject, result.content); + final result = NetworkPackage.fromJson(jsonDecode(event)); + switch (result.method) { + case 'notifications.new': + final result = model.Notification.fromJson(jsonDecode(event)); + nty.onRemoteMessage(result); + nty.notifyMessage(result.subject, result.content); + } }, onError: (_, __) => connect(), onDone: () => connect(), diff --git a/lib/widgets/posts/attachment_editor.dart b/lib/widgets/posts/attachment_editor.dart index ca837c2..995ae23 100755 --- a/lib/widgets/posts/attachment_editor.dart +++ b/lib/widgets/posts/attachment_editor.dart @@ -11,7 +11,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/post.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/utils/file.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:solian/widgets/exts.dart'; diff --git a/lib/widgets/posts/comment_list.dart b/lib/widgets/posts/comment_list.dart index 9c81ae0..c6d29ea 100644 --- a/lib/widgets/posts/comment_list.dart +++ b/lib/widgets/posts/comment_list.dart @@ -9,7 +9,7 @@ import 'package:http/http.dart' as http; import 'package:solian/providers/auth.dart'; import 'package:solian/router.dart'; import 'package:solian/screens/posts/comment_editor.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/posts/post.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; diff --git a/lib/widgets/posts/content/article.dart b/lib/widgets/posts/content/article.dart index 8d8ed31..974b37b 100644 --- a/lib/widgets/posts/content/article.dart +++ b/lib/widgets/posts/content/article.dart @@ -4,7 +4,7 @@ import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:solian/models/post.dart'; import 'package:markdown/markdown.dart' as markdown; import 'package:solian/utils/platform.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:url_launcher/url_launcher_string.dart'; class ArticleContent extends StatelessWidget { diff --git a/lib/widgets/posts/content/attachment.dart b/lib/widgets/posts/content/attachment.dart index 556990b..9148d61 100644 --- a/lib/widgets/posts/content/attachment.dart +++ b/lib/widgets/posts/content/attachment.dart @@ -4,7 +4,7 @@ import 'package:media_kit/media_kit.dart'; import 'package:media_kit_video/media_kit_video.dart'; import 'package:solian/models/post.dart'; import 'package:solian/utils/platform.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:flutter_carousel_widget/flutter_carousel_widget.dart'; import 'package:solian/widgets/posts/attachment_screen.dart'; import 'package:uuid/uuid.dart'; diff --git a/lib/widgets/posts/post_deletion.dart b/lib/widgets/posts/post_deletion.dart index 8012e0e..994b626 100644 --- a/lib/widgets/posts/post_deletion.dart +++ b/lib/widgets/posts/post_deletion.dart @@ -5,7 +5,7 @@ import 'package:provider/provider.dart'; import 'package:solian/models/post.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/exts.dart'; class ItemDeletionDialog extends StatefulWidget { diff --git a/lib/widgets/posts/reaction_action.dart b/lib/widgets/posts/reaction_action.dart index b200735..8fa69ba 100644 --- a/lib/widgets/posts/reaction_action.dart +++ b/lib/widgets/posts/reaction_action.dart @@ -5,7 +5,7 @@ import 'package:flutter_animate/flutter_animate.dart'; import 'package:provider/provider.dart'; import 'package:solian/models/reaction.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:solian/widgets/exts.dart'; diff --git a/lib/widgets/realms/realm_deletion.dart b/lib/widgets/realms/realm_deletion.dart index a77e0e0..a1ca187 100644 --- a/lib/widgets/realms/realm_deletion.dart +++ b/lib/widgets/realms/realm_deletion.dart @@ -5,7 +5,7 @@ import 'package:provider/provider.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:solian/models/realm.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/utils/service_url.dart'; +import 'package:solian/utils/services_url.dart'; import 'package:solian/widgets/exts.dart'; class RealmDeletion extends StatefulWidget { diff --git a/pubspec.lock b/pubspec.lock index 6821f5c..1421bcd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.5.0" + asn1lib: + dependency: transitive + description: + name: asn1lib + sha256: c9c85fedbe2188b95133cbe960e16f5f448860f7133330e272edbbca5893ddc6 + url: "https://pub.dev" + source: hosted + version: "1.5.2" async: dependency: transitive description: @@ -217,6 +225,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" + encrypt: + dependency: "direct main" + description: + name: encrypt + sha256: "62d9aa4670cc2a8798bab89b39fc71b6dfbacf615de6cf5001fb39f7e4a996a2" + url: "https://pub.dev" + source: hosted + version: "5.0.3" fake_async: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d9f765c..2977ed9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -72,6 +72,7 @@ dependencies: cached_network_image: ^3.3.1 desktop_drop: ^0.4.4 easy_debounce: ^2.0.3 + encrypt: ^5.0.3 dev_dependencies: flutter_test: diff --git a/web/favicon.png b/web/favicon.png old mode 100644 new mode 100755 index 170be8c..e414a9d Binary files a/web/favicon.png and b/web/favicon.png differ