feat: 用户资料 API(Protobuf)

This commit is contained in:
HuanCheng65 2023-02-01 16:02:26 +08:00
parent 72b14338dc
commit f40fcf2eb0
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
5 changed files with 60 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import com.huanchengfly.tieba.post.api.models.protos.forumRecommend.ForumRecomme
import com.huanchengfly.tieba.post.api.models.protos.frsPage.FrsPageResponse
import com.huanchengfly.tieba.post.api.models.protos.hotThreadList.HotThreadListResponse
import com.huanchengfly.tieba.post.api.models.protos.personalized.PersonalizedResponse
import com.huanchengfly.tieba.post.api.models.protos.profile.ProfileResponse
import com.huanchengfly.tieba.post.api.models.protos.threadList.ThreadListResponse
import com.huanchengfly.tieba.post.api.models.protos.topicList.TopicListResponse
import com.huanchengfly.tieba.post.api.models.protos.userLike.UserLikeResponse
@ -1215,4 +1216,13 @@ interface ITiebaApi {
postId: String? = null,
replyUserId: String? = null
): Flow<AddPostBean>
/**
* 用户信息Flow
*
* @param uid 用户 ID
*/
fun profileFlow(
uid: Long
): Flow<ProfileResponse>
}

View File

@ -59,6 +59,9 @@ import com.huanchengfly.tieba.post.api.models.protos.hotThreadList.HotThreadList
import com.huanchengfly.tieba.post.api.models.protos.personalized.PersonalizedRequest
import com.huanchengfly.tieba.post.api.models.protos.personalized.PersonalizedRequestData
import com.huanchengfly.tieba.post.api.models.protos.personalized.PersonalizedResponse
import com.huanchengfly.tieba.post.api.models.protos.profile.ProfileRequest
import com.huanchengfly.tieba.post.api.models.protos.profile.ProfileRequestData
import com.huanchengfly.tieba.post.api.models.protos.profile.ProfileResponse
import com.huanchengfly.tieba.post.api.models.protos.threadList.AdParam
import com.huanchengfly.tieba.post.api.models.protos.threadList.ThreadListRequest
import com.huanchengfly.tieba.post.api.models.protos.threadList.ThreadListRequestData
@ -971,4 +974,31 @@ object MixedTiebaApiImpl : ITiebaApi {
post_from = if (postId == null) "3" else "11"
)
}
override fun profileFlow(uid: Long): Flow<ProfileResponse> {
val selfUid = AccountUtil.getUid()?.toLongOrNull()
val isSelf = selfUid == uid
return RetrofitTiebaApi.OFFICIAL_PROTOBUF_TIEBA_API.profileFlow(
buildProtobufRequestBody(
ProfileRequest(
ProfileRequestData(
common = buildCommonRequest(),
friend_uid = uid.takeIf { !isSelf },
friend_uid_portrait = "",
has_plist = 1,
is_from_usercenter = 1,
need_post_count = 1,
page = 2,
pn = 1,
q_type = 0,
rn = 20,
scr_dip = App.ScreenInfo.DENSITY.toDouble(),
scr_h = getScreenHeight(),
scr_w = getScreenWidth(),
uid = selfUid,
)
)
)
)
}
}

View File

@ -4,6 +4,7 @@ import com.huanchengfly.tieba.post.api.models.protos.forumRecommend.ForumRecomme
import com.huanchengfly.tieba.post.api.models.protos.frsPage.FrsPageResponse
import com.huanchengfly.tieba.post.api.models.protos.hotThreadList.HotThreadListResponse
import com.huanchengfly.tieba.post.api.models.protos.personalized.PersonalizedResponse
import com.huanchengfly.tieba.post.api.models.protos.profile.ProfileResponse
import com.huanchengfly.tieba.post.api.models.protos.threadList.ThreadListResponse
import com.huanchengfly.tieba.post.api.models.protos.topicList.TopicListResponse
import com.huanchengfly.tieba.post.api.models.protos.userLike.UserLikeResponse
@ -47,4 +48,9 @@ interface OfficialProtobufTiebaApi {
fun threadListFlow(
@Body body: MyMultipartBody,
): Flow<ThreadListResponse>
@POST("/c/u/user/profile?cmd=303012")
fun profileFlow(
@Body body: MyMultipartBody,
): Flow<ProfileResponse>
}

View File

@ -12,19 +12,19 @@ import "Error.proto";
message ProfileRequestData {
CommonRequest common = 9;
int64 friend_uid = 3;
string friend_uid_portrait = 16;
optional int64 friend_uid = 3;
optional string friend_uid_portrait = 16;
uint32 has_plist = 8;
int32 is_from_usercenter = 14;
uint32 need_post_count = 2;
int32 page = 15;
uint32 pn = 6;
uint32 q_type = 12;
optional uint32 q_type = 12;
uint32 rn = 7;
double scr_dip = 13;
int32 scr_h = 11;
int32 scr_w = 10;
int64 uid = 1;
optional int64 uid = 1;
}
message ProfileRequest {

View File

@ -17,10 +17,20 @@ message User {
int32 is_manager = 11;
int32 is_bawu = 25;
string bawu_type = 26;
int32 fans_num = 30;
int32 concern_num = 31;
int32 sex = 32;
int32 my_like_num = 33;
string intro = 34;
int32 has_concerned = 35;
int32 post_num = 37;
string tb_age = 38;
int32 gender = 42;
PrivSets privSets = 45;
string fansNickname = 57;
int32 thread_num = 87;
int32 agree_num = 88;
int32 priv_thread = 92;
int32 isDefaultAvatar = 106;
uint32 total_agree_num = 118;
}