Merge remote-tracking branch 'origin/master'

This commit is contained in:
whitechi73 2024-01-20 03:03:07 +08:00
commit 48b720bdd7
7 changed files with 27 additions and 28 deletions

View File

@ -179,7 +179,7 @@ internal object GroupSvc: BaseSvc() {
var troopList = service.allTroopList var troopList = service.allTroopList
if(refresh || !service.isTroopCacheInited || troopList == null) { if(refresh || !service.isTroopCacheInited || troopList == null) {
if(!requestGroupList(service)) { if(!requestGroupInfo(service)) {
return Result.failure(Exception("获取群列表失败")) return Result.failure(Exception("获取群列表失败"))
} else { } else {
troopList = service.allTroopList troopList = service.allTroopList
@ -192,15 +192,14 @@ internal object GroupSvc: BaseSvc() {
val service = app val service = app
.getRuntimeService(ITroopInfoService::class.java, "all") .getRuntimeService(ITroopInfoService::class.java, "all")
var groupInfo = getGroupInfo(groupId) val groupInfo = getGroupInfo(groupId)
if(refresh || !service.isTroopCacheInited || groupInfo.troopuin.isNullOrBlank()) { return if(refresh || !service.isTroopCacheInited || groupInfo.troopuin.isNullOrBlank()) {
groupInfo = requestGroupList(service, groupId.toLong()).onFailure { requestGroupInfo(service, groupId.toLong())
return Result.failure(it) } else {
}.getOrThrow() Result.success(groupInfo)
} }
return Result.success(groupInfo)
} }
suspend fun setGroupUniqueTitle(groupId: String, userId: String, title: String) { suspend fun setGroupUniqueTitle(groupId: String, userId: String, title: String) {
@ -209,7 +208,7 @@ internal object GroupSvc: BaseSvc() {
req.uint64_group_code.set(groupId.toLong()) req.uint64_group_code.set(groupId.toLong())
val memberInfo = Oidb_0x8fc.MemberInfo() val memberInfo = Oidb_0x8fc.MemberInfo()
memberInfo.uint64_uin.set(userId.toLong()) memberInfo.uint64_uin.set(userId.toLong())
memberInfo.bytes_uin_name.set(ByteStringMicro.copyFromUtf8(localMemberInfo.troopnick.ifBlank { memberInfo.bytes_uin_name.set(ByteStringMicro.copyFromUtf8(localMemberInfo.troopnick.ifEmpty {
localMemberInfo.troopremark.ifNullOrEmpty("") localMemberInfo.troopremark.ifNullOrEmpty("")
})) }))
memberInfo.bytes_special_title.set(ByteStringMicro.copyFromUtf8(title)) memberInfo.bytes_special_title.set(ByteStringMicro.copyFromUtf8(title))
@ -561,7 +560,7 @@ internal object GroupSvc: BaseSvc() {
} }
} }
private suspend fun requestGroupList( private suspend fun requestGroupInfo(
service: ITroopInfoService service: ITroopInfoService
): Boolean { ): Boolean {
refreshTroopList() refreshTroopList()
@ -654,9 +653,9 @@ internal object GroupSvc: BaseSvc() {
METHOD_REQ_MEMBER_INFO_V2.invoke(businessHandler, groupId.toString(), groupUin2GroupCode(groupId).toString(), arrayListOf(memberUin.toString())) METHOD_REQ_MEMBER_INFO_V2.invoke(businessHandler, groupId.toString(), groupUin2GroupCode(groupId).toString(), arrayListOf(memberUin.toString()))
} }
private suspend fun requestGroupList(dataService: ITroopInfoService, uin: Long): Result<TroopInfo> { private suspend fun requestGroupInfo(dataService: ITroopInfoService, uin: Long): Result<TroopInfo> {
val strUin = uin.toString() val strUin = uin.toString()
val list = withTimeoutOrNull(5000) { val info = withTimeoutOrNull(5000) {
var troopInfo: TroopInfo? var troopInfo: TroopInfo?
do { do {
troopInfo = dataService.getTroopInfo(strUin) troopInfo = dataService.getTroopInfo(strUin)
@ -664,8 +663,8 @@ internal object GroupSvc: BaseSvc() {
} while (troopInfo == null || troopInfo.troopuin.isNullOrBlank()) } while (troopInfo == null || troopInfo.troopuin.isNullOrBlank())
return@withTimeoutOrNull troopInfo return@withTimeoutOrNull troopInfo
} }
return if (list != null) { return if (info != null) {
Result.success(list) Result.success(info)
} else { } else {
Result.failure(Exception("获取群列表失败")) Result.failure(Exception("获取群列表失败"))
} }

View File

@ -37,9 +37,9 @@ internal object GetForwardMsg: IActionHandler() {
realId = msg.msgSeq.toInt(), realId = msg.msgSeq.toInt(),
sender = MessageSender( sender = MessageSender(
msg.senderUin, msg.sendNickName msg.senderUin, msg.sendNickName
.ifBlank { msg.sendMemberName } .ifEmpty { msg.sendMemberName }
.ifBlank { msg.sendRemarkName } .ifEmpty { msg.sendRemarkName }
.ifBlank { msg.peerName }, "unknown", 0, msg.senderUid .ifEmpty { msg.peerName }, "unknown", 0, msg.senderUid
), ),
message = MessageConvert.convertMessageRecordToMsgSegment(msg).map { message = MessageConvert.convertMessageRecordToMsgSegment(msg).map {
it.toJson() it.toJson()

View File

@ -85,9 +85,9 @@ internal object GetHistoryMsg: IActionHandler() {
realId = seq, realId = seq,
sender = MessageSender( sender = MessageSender(
msg.senderUin, msg.sendNickName msg.senderUin, msg.sendNickName
.ifBlank { msg.sendMemberName } .ifEmpty { msg.sendMemberName }
.ifBlank { msg.sendRemarkName } .ifEmpty { msg.sendRemarkName }
.ifBlank { msg.peerName }, "unknown", 0, msg.senderUid .ifEmpty { msg.peerName }, "unknown", 0, msg.senderUid
), ),
message = MessageConvert.convertMessageRecordToMsgSegment(msg).map { message = MessageConvert.convertMessageRecordToMsgSegment(msg).map {
it.toJson() it.toJson()

View File

@ -30,9 +30,9 @@ internal object GetMsg: IActionHandler() {
realId = seq, realId = seq,
sender = MessageSender( sender = MessageSender(
msg.senderUin, msg.sendNickName msg.senderUin, msg.sendNickName
.ifBlank { msg.sendMemberName } .ifEmpty { msg.sendMemberName }
.ifBlank { msg.sendRemarkName } .ifEmpty { msg.sendRemarkName }
.ifBlank { msg.peerName }, "unknown", 0, msg.senderUid .ifEmpty { msg.peerName }, "unknown", 0, msg.senderUid
), ),
message = MessageConvert.convertMessageRecordToMsgSegment(msg).map { message = MessageConvert.convertMessageRecordToMsgSegment(msg).map {
it.toJson() it.toJson()

View File

@ -29,7 +29,7 @@ internal object GetProfileCard: IActionHandler() {
uin = card.uin.toLong(), uin = card.uin.toLong(),
name = card.strNick, name = card.strNick,
mail = card.strShowName ?: card.strEmail ?: "", mail = card.strShowName ?: card.strEmail ?: "",
remark = card.strReMark.let { if (it.isNullOrBlank()) card.strAutoRemark else it }, remark = card.strReMark.let { if (it.isNullOrEmpty()) card.strAutoRemark else it },
findMethod = card.addSrcName, findMethod = card.addSrcName,
displayName = card.strContactName, displayName = card.strContactName,
maxVoteCnt = card.bAvailVoteCnt, maxVoteCnt = card.bAvailVoteCnt,

View File

@ -30,7 +30,7 @@ internal object GetTroopHonor: IActionHandler() {
GroupSvc.parseHonor(member.honorList).forEach { GroupSvc.parseHonor(member.honorList).forEach {
val honor = nativeDecodeHonor(member.memberuin, it, member.mHonorRichFlag) val honor = nativeDecodeHonor(member.memberuin, it, member.mHonorRichFlag)
if (honor != null) { if (honor != null) {
honor.nick = member.troopnick.ifBlank { member.friendnick } honor.nick = member.troopnick.ifEmpty { member.friendnick }
honorInfo.add(honor) honorInfo.add(honor)
} }
} }

View File

@ -82,9 +82,9 @@ internal object GlobalEventTransmitter: BaseSvc() {
sender = Sender( sender = Sender(
userId = record.senderUin, userId = record.senderUin,
nickname = record.sendNickName nickname = record.sendNickName
.ifBlank { record.sendRemarkName } .ifEmpty { record.sendRemarkName }
.ifBlank { record.sendMemberName } .ifEmpty { record.sendMemberName }
.ifBlank { record.peerName }, .ifEmpty { record.peerName },
card = record.sendMemberName, card = record.sendMemberName,
role = when (record.senderUin) { role = when (record.senderUin) {
GroupSvc.getOwner(record.peerUin.toString()) -> MemberRole.Owner GroupSvc.getOwner(record.peerUin.toString()) -> MemberRole.Owner
@ -112,7 +112,7 @@ internal object GlobalEventTransmitter: BaseSvc() {
): Boolean { ): Boolean {
val botUin = app.longAccountUin val botUin = app.longAccountUin
var nickName = record.sendNickName var nickName = record.sendNickName
if (nickName.isNullOrBlank()) { if (nickName.isNullOrEmpty()) {
CardSvc.getProfileCard(record.senderUin.toString()).onSuccess { CardSvc.getProfileCard(record.senderUin.toString()).onSuccess {
nickName = it.strNick ?: record.peerName nickName = it.strNick ?: record.peerName
} }