From 6a6f350cc3a7c465d5618cd2af4b0c6efc85824b Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:14:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(API):=20=E5=90=A7=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=8E=86=E5=8F=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tieba/post/api/interfaces/ITiebaApi.kt | 8 +++++ .../api/interfaces/impls/MixedTiebaApiImpl.kt | 18 +++++++++++ .../interfaces/OfficialProtobufTiebaApi.kt | 6 ++++ .../tieba/post/models/HistoryForumItem.kt | 12 +++++++ .../GetHistoryForumRequest.proto | 12 +++++++ .../GetHistoryForumRequestData.proto | 12 +++++++ .../GetHistoryForumResponse.proto | 14 ++++++++ .../GetHistoryForumResponseData.proto | 14 ++++++++ app/src/main/protos/HistoryForumInfo.proto | 32 +++++++++++++++++++ 9 files changed, 128 insertions(+) create mode 100644 app/src/main/java/com/huanchengfly/tieba/post/models/HistoryForumItem.kt create mode 100644 app/src/main/protos/GetHistoryForum/GetHistoryForumRequest.proto create mode 100644 app/src/main/protos/GetHistoryForum/GetHistoryForumRequestData.proto create mode 100644 app/src/main/protos/GetHistoryForum/GetHistoryForumResponse.proto create mode 100644 app/src/main/protos/GetHistoryForum/GetHistoryForumResponseData.proto create mode 100644 app/src/main/protos/HistoryForumInfo.proto diff --git a/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/ITiebaApi.kt b/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/ITiebaApi.kt index fb0ee5e0..1eeb2d97 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/ITiebaApi.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/ITiebaApi.kt @@ -10,6 +10,7 @@ import com.huanchengfly.tieba.post.api.models.protos.forumRuleDetail.ForumRuleDe import com.huanchengfly.tieba.post.api.models.protos.frsPage.FrsPageResponse import com.huanchengfly.tieba.post.api.models.protos.getBawuInfo.GetBawuInfoResponse import com.huanchengfly.tieba.post.api.models.protos.getForumDetail.GetForumDetailResponse +import com.huanchengfly.tieba.post.api.models.protos.getHistoryForum.GetHistoryForumResponse import com.huanchengfly.tieba.post.api.models.protos.getLevelInfo.GetLevelInfoResponse import com.huanchengfly.tieba.post.api.models.protos.getMemberInfo.GetMemberInfoResponse import com.huanchengfly.tieba.post.api.models.protos.getUserInfo.GetUserInfoResponse @@ -1508,4 +1509,11 @@ interface ITiebaApi { bduss: String?, sToken: String?, ): Flow + + /** + * 获取吧浏览历史信息 + */ + fun getHistoryForumFlow( + history: String, + ): Flow } \ No newline at end of file diff --git a/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/impls/MixedTiebaApiImpl.kt b/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/impls/MixedTiebaApiImpl.kt index ed711f4d..6230c1b2 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/impls/MixedTiebaApiImpl.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/impls/MixedTiebaApiImpl.kt @@ -66,6 +66,9 @@ import com.huanchengfly.tieba.post.api.models.protos.getBawuInfo.GetBawuInfoResp import com.huanchengfly.tieba.post.api.models.protos.getForumDetail.GetForumDetailRequest import com.huanchengfly.tieba.post.api.models.protos.getForumDetail.GetForumDetailRequestData import com.huanchengfly.tieba.post.api.models.protos.getForumDetail.GetForumDetailResponse +import com.huanchengfly.tieba.post.api.models.protos.getHistoryForum.GetHistoryForumRequest +import com.huanchengfly.tieba.post.api.models.protos.getHistoryForum.GetHistoryForumRequestData +import com.huanchengfly.tieba.post.api.models.protos.getHistoryForum.GetHistoryForumResponse import com.huanchengfly.tieba.post.api.models.protos.getLevelInfo.GetLevelInfoRequest import com.huanchengfly.tieba.post.api.models.protos.getLevelInfo.GetLevelInfoRequestData import com.huanchengfly.tieba.post.api.models.protos.getLevelInfo.GetLevelInfoResponse @@ -1453,4 +1456,19 @@ object MixedTiebaApiImpl : ITiebaApi { ) ) } + + override fun getHistoryForumFlow(history: String): Flow { + return RetrofitTiebaApi.OFFICIAL_PROTOBUF_TIEBA_V12_API.getHistoryForumFlow( + buildProtobufRequestBody( + GetHistoryForumRequest( + GetHistoryForumRequestData( + common = buildCommonRequest(clientVersion = ClientVersion.TIEBA_V12), + history = history, + ) + ), + clientVersion = ClientVersion.TIEBA_V12, + needSToken = true + ) + ) + } } \ No newline at end of file diff --git a/app/src/main/java/com/huanchengfly/tieba/post/api/retrofit/interfaces/OfficialProtobufTiebaApi.kt b/app/src/main/java/com/huanchengfly/tieba/post/api/retrofit/interfaces/OfficialProtobufTiebaApi.kt index 00b49569..aae88e31 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/api/retrofit/interfaces/OfficialProtobufTiebaApi.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/api/retrofit/interfaces/OfficialProtobufTiebaApi.kt @@ -6,6 +6,7 @@ import com.huanchengfly.tieba.post.api.models.protos.forumRuleDetail.ForumRuleDe import com.huanchengfly.tieba.post.api.models.protos.frsPage.FrsPageResponse import com.huanchengfly.tieba.post.api.models.protos.getBawuInfo.GetBawuInfoResponse import com.huanchengfly.tieba.post.api.models.protos.getForumDetail.GetForumDetailResponse +import com.huanchengfly.tieba.post.api.models.protos.getHistoryForum.GetHistoryForumResponse import com.huanchengfly.tieba.post.api.models.protos.getLevelInfo.GetLevelInfoResponse import com.huanchengfly.tieba.post.api.models.protos.getMemberInfo.GetMemberInfoResponse import com.huanchengfly.tieba.post.api.models.protos.getUserInfo.GetUserInfoResponse @@ -121,4 +122,9 @@ interface OfficialProtobufTiebaApi { fun getUserInfoFlow( @Body body: MyMultipartBody, ): Flow + + @POST("/c/f/forum/gethistoryforum?cmd=309601&format=protobuf") + fun getHistoryForumFlow( + @Body body: MyMultipartBody, + ): Flow } \ No newline at end of file diff --git a/app/src/main/java/com/huanchengfly/tieba/post/models/HistoryForumItem.kt b/app/src/main/java/com/huanchengfly/tieba/post/models/HistoryForumItem.kt new file mode 100644 index 00000000..604eafbb --- /dev/null +++ b/app/src/main/java/com/huanchengfly/tieba/post/models/HistoryForumItem.kt @@ -0,0 +1,12 @@ +package com.huanchengfly.tieba.post.models + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class HistoryForumItem( + @SerialName("forum_id") + val forumId: Long, + @SerialName("visit_time") + val visitTime: String, +) diff --git a/app/src/main/protos/GetHistoryForum/GetHistoryForumRequest.proto b/app/src/main/protos/GetHistoryForum/GetHistoryForumRequest.proto new file mode 100644 index 00000000..a0fc85e1 --- /dev/null +++ b/app/src/main/protos/GetHistoryForum/GetHistoryForumRequest.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package tieba.getHistoryForum; + +option java_package = "com.huanchengfly.tieba.post.api.models.protos.getHistoryForum"; + + +import "GetHistoryForum/GetHistoryForumRequestData.proto"; + +message GetHistoryForumRequest { + GetHistoryForumRequestData data = 1; +} diff --git a/app/src/main/protos/GetHistoryForum/GetHistoryForumRequestData.proto b/app/src/main/protos/GetHistoryForum/GetHistoryForumRequestData.proto new file mode 100644 index 00000000..00fad3b8 --- /dev/null +++ b/app/src/main/protos/GetHistoryForum/GetHistoryForumRequestData.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package tieba.getHistoryForum; + +option java_package = "com.huanchengfly.tieba.post.api.models.protos.getHistoryForum"; + +import "CommonRequest.proto"; + +message GetHistoryForumRequestData { + CommonRequest common = 1; + string history = 2; +} diff --git a/app/src/main/protos/GetHistoryForum/GetHistoryForumResponse.proto b/app/src/main/protos/GetHistoryForum/GetHistoryForumResponse.proto new file mode 100644 index 00000000..a5890691 --- /dev/null +++ b/app/src/main/protos/GetHistoryForum/GetHistoryForumResponse.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package tieba.getHistoryForum; + +option java_package = "com.huanchengfly.tieba.post.api.models.protos.getHistoryForum"; + + +import "Error.proto"; +import "GetHistoryForum/GetHistoryForumResponseData.proto"; + +message GetHistoryForumResponse { + Error error = 1; + GetHistoryForumResponseData data = 2; +} diff --git a/app/src/main/protos/GetHistoryForum/GetHistoryForumResponseData.proto b/app/src/main/protos/GetHistoryForum/GetHistoryForumResponseData.proto new file mode 100644 index 00000000..b88a8b9f --- /dev/null +++ b/app/src/main/protos/GetHistoryForum/GetHistoryForumResponseData.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package tieba.getHistoryForum; + +option java_package = "com.huanchengfly.tieba.post.api.models.protos.getHistoryForum"; + +import "FrsTabInfo.proto"; +import "HistoryForumInfo.proto"; + +message GetHistoryForumResponseData { + repeated HistoryForumInfo history_forum = 1; + repeated FrsTabInfo nav_tab_info = 2; + repeated HistoryForumInfo this_week_forums = 3; +} diff --git a/app/src/main/protos/HistoryForumInfo.proto b/app/src/main/protos/HistoryForumInfo.proto new file mode 100644 index 00000000..9c2e18ac --- /dev/null +++ b/app/src/main/protos/HistoryForumInfo.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; + +package tieba; + +option java_package = "com.huanchengfly.tieba.post.api.models.protos"; + +import "BlockPopInfo.proto"; +import "FrsTabInfo.proto"; +import "RecomTagInfo.proto"; +import "ThemeColorInfo.proto"; +import "PostPrefix.proto"; + +message HistoryForumInfo { + int64 forum_id = 1; + string forum_name = 2; + string avatar = 3; + int32 is_liveforum = 4; + int32 unread_num = 5; + string visit_time = 6; + int32 follow_num = 7; + ThemeColorInfo theme_color = 8; + bool need_trans = 10; + BlockPopInfo block_pop_info = 14; + uint32 hot_num = 15; + int32 level_id = 16; + repeated FrsTabInfo tab_info = 17; + bool has_postpre = 18; + PostPrefix post_prefix = 19; + int32 is_forum_business_account = 20; + RecomTagInfo tag_info = 21; + string first_category = 22; +}