diff --git a/lib/http/api.dart b/lib/http/api.dart index 05fc022f..d881f707 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -328,7 +328,22 @@ class Api { // 获取指定分组下的up static const String followUpGroup = '/x/relation/tag'; + // 获取消息中心未读信息 static const String msgFeedUnread = '/x/msgfeed/unread'; + //https://api.bilibili.com/x/msgfeed/reply?platform=web&build=0&mobi_app=web + static const String msgFeedReply = '/x/msgfeed/reply'; + //https://api.bilibili.com/x/msgfeed/at?platform=web&build=0&mobi_app=web + static const String msgFeedAt = '/x/msgfeed/at'; + //https://api.bilibili.com/x/msgfeed/like?platform=web&build=0&mobi_app=web + static const String msgFeedLike = '/x/msgfeed/like'; + //https://message.bilibili.com/x/sys-msg/query_user_notify?csrf=31b0caa533cea4d1a1bd2e921f045ec6&csrf=31b0caa533cea4d1a1bd2e921f045ec6&page_size=20&build=0&mobi_app=web + static const String msgSysUserNotify = '${HttpString.messageBaseUrl}/x/sys-msg/query_user_notify'; + //https://message.bilibili.com/x/sys-msg/query_unified_notify?csrf=31b0caa533cea4d1a1bd2e921f045ec6&csrf=31b0caa533cea4d1a1bd2e921f045ec6&page_size=10&build=0&mobi_app=web + static const String msgSysUnifiedNotify = '${HttpString.messageBaseUrl}/x/sys-msg/query_unified_notify'; + + // 系统信息光标更新(已读标记) + //https://message.bilibili.com/x/sys-msg/update_cursor?csrf=31b0caa533cea4d1a1bd2e921f045ec6&csrf=31b0caa533cea4d1a1bd2e921f045ec6&cursor=1705288500000000000&has_up=0&build=0&mobi_app=web + static const String msgSysUpdateCursor = '${HttpString.messageBaseUrl}/x/sys-msg/update_cursor'; /// 私聊 /// 'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions? @@ -372,7 +387,7 @@ class Api { /// mobi_app: web /// csrf_token: /// csrf: - static const String updateAck = + static const String ackSessionMsg = '${HttpString.tUrl}/session_svr/v1/session_svr/update_ack'; // 获取某个动态详情 diff --git a/lib/http/constants.dart b/lib/http/constants.dart index 3d749ee8..cad413ef 100644 --- a/lib/http/constants.dart +++ b/lib/http/constants.dart @@ -5,6 +5,7 @@ class HttpString { static const String appBaseUrl = 'https://app.bilibili.com'; static const String liveBaseUrl = 'https://api.live.bilibili.com'; static const String passBaseUrl = 'https://passport.bilibili.com'; + static const String messageBaseUrl = 'https://message.bilibili.com'; static const List validateStatusCodes = [ 302, 304, diff --git a/lib/http/msg.dart b/lib/http/msg.dart index e460852a..9c8fb7bf 100644 --- a/lib/http/msg.dart +++ b/lib/http/msg.dart @@ -102,4 +102,35 @@ class MsgHttp { }; } } + + static Future ackSessionMsg({ + int? talkerId, + int? ackSeqno, + }) async { + String csrf = await Request.getCsrf(); + Map params = await WbiSign().makSign({ + 'talker_id': talkerId, + 'session_type': 1, + 'ack_seqno': ackSeqno, + 'build': 0, + 'mobi_app': 'web', + 'csrf_token': csrf, + 'csrf': csrf + }); + var res = await Request().get(Api.ackSessionMsg, data: params); + if (res.data['code'] == 0) { + return { + 'status': true, + 'data': res.data['data'], + }; + } else { + return { + 'status': false, + 'date': [], + 'msg': "message: ${res.data['message']}," + " msg: ${res.data['msg']}," + " code: ${res.data['code']}", + }; + } + } } diff --git a/lib/pages/whisper_detail/controller.dart b/lib/pages/whisper_detail/controller.dart index 52a70c49..a07079d8 100644 --- a/lib/pages/whisper_detail/controller.dart +++ b/lib/pages/whisper_detail/controller.dart @@ -1,3 +1,4 @@ +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:pilipala/http/msg.dart'; import 'package:pilipala/models/msg/session.dart'; @@ -25,4 +26,19 @@ class WhisperDetailController extends GetxController { } return res; } + + Future ackSessionMsg() async { + if (messageList.isEmpty){ + return; + } + var res = await MsgHttp.ackSessionMsg( + talkerId: talkerId, + ackSeqno: messageList.last.msgSeqno, + ); + if (res['status']) { + SmartDialog.showToast("已读成功"); + } else { + SmartDialog.showToast(res['msg']); + } + } } diff --git a/lib/pages/whisper_detail/view.dart b/lib/pages/whisper_detail/view.dart index 5d108037..ca256c84 100644 --- a/lib/pages/whisper_detail/view.dart +++ b/lib/pages/whisper_detail/view.dart @@ -99,6 +99,7 @@ class _WhisperDetailPageState extends State { final Map data = snapshot.data as Map; if (data['status']) { List messageList = _whisperDetailController.messageList; + _whisperDetailController.ackSessionMsg(); return Obx( () => messageList.isEmpty ? const SizedBox()