Skip to content

Commit c5b240c

Browse files
committed
1. 改正日志实例的类
1 parent 225d494 commit c5b240c

File tree

6 files changed

+52
-31
lines changed

6 files changed

+52
-31
lines changed

wechaty-puppet-hostie/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
<groupId>org.apache.commons</groupId>
6363
<artifactId>commons-lang3</artifactId>
6464
</dependency>
65-
6665
</dependencies>
6766

6867
<build>

wechaty-puppet-hostie/src/main/kotlin/io/github/wechaty/grpc/GrpcPuppet.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
389389
}
390390

391391
override fun contactRawPayload(contractId: String): Future<ContactPayload> {
392-
393392
val request = Contact.ContactPayloadRequest.newBuilder()
394393
.setId(contractId)
395394
.build()

wechaty-puppet/src/main/kotlin/Puppet.kt

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import io.github.wechaty.memorycard.MemoryCard
1818
import io.github.wechaty.schemas.*
1919
import io.github.wechaty.utils.FutureUtils
2020
import io.github.wechaty.utils.JsonUtils
21+
import okhttp3.internal.toImmutableList
2122
import org.apache.commons.collections4.CollectionUtils
2223
import org.apache.commons.lang3.StringUtils
2324
import org.slf4j.LoggerFactory
@@ -447,13 +448,13 @@ abstract class Puppet : EventEmitter {
447448

448449
if (StringUtils.isNotBlank(query.id)) {
449450
stream = stream?.filter {
450-
StringUtils.equals(query.alias, it.alias)
451+
StringUtils.equals(query.id, it.id)
451452
}
452453
}
453454

454455
if (StringUtils.isNotBlank(query.weixin)) {
455456
stream = stream?.filter {
456-
StringUtils.equals(query.alias, it.alias)
457+
StringUtils.equals(query.weixin, it.weixin)
457458
}
458459
}
459460

@@ -825,37 +826,35 @@ abstract class Puppet : EventEmitter {
825826
abstract fun roomMemberList(roomId: String): Future<List<String>>
826827

827828
fun roomMemberSearch(roomId: String, query: RoomMemberQueryFilter): Future<List<String>> {
828-
TODO()
829-
}
830-
831-
fun roomReach(query: RoomQueryFilter?): Future<List<String>> {
832-
TODO()
833-
}
834-
835-
fun roomValidate(roomId: String): Future<Boolean> {
836-
return CompletableFuture.completedFuture(true)
837-
}
829+
return CompletableFuture.supplyAsync {
830+
val roomMemberIdList = roomMemberList(roomId).get()
838831

839-
fun roomPayloadCache(roomId: String): RoomPayload? {
840-
return cacheRoomPayload.getIfPresent(roomId)
841-
}
832+
val contactQuery = if (query.name != null || query.contactAlias != null) {
833+
val contactQueryFilter = ContactQueryFilter()
834+
contactQueryFilter.name = query.name
835+
contactQueryFilter
836+
}
837+
else {
838+
val contactQueryFilter = ContactQueryFilter()
839+
contactQueryFilter.alias = query.contactAlias
840+
contactQueryFilter
841+
}
842842

843+
var idList = ArrayList(contactSearch(contactQuery, roomMemberIdList).get())
844+
val memberPayloadList = roomMemberIdList.mapNotNull { x -> roomMemberPayload(roomId, x).get() }
843845

844-
fun roomPayload(roomId: String): Future<RoomPayload> {
845-
return CompletableFuture.supplyAsync {
846-
return@supplyAsync cacheRoomPayload.get(roomId) { t: String ->
847-
val get = roomRawPayload(t).get()
848-
return@get roomRawPayloadParser(get).get()
846+
if (query.roomAlias != null) {
847+
val result = memberPayloadList.filter { payload ->
848+
payload.roomAlias === query.roomAlias
849+
}.map { payload ->
850+
payload.id
851+
}
852+
idList.addAll(result)
849853
}
854+
return@supplyAsync idList;
850855
}
851856
}
852857

853-
fun roomPayloadDirty(roomId: String): Future<Void> {
854-
cacheRoomPayload.invalidate(roomId)
855-
return CompletableFuture.completedFuture(null)
856-
}
857-
858-
859858
fun roomSearch(query: RoomQueryFilter): Future<List<String>> {
860859
return CompletableFuture.supplyAsync {
861860
val allRoomList = roomList().get()
@@ -885,6 +884,30 @@ abstract class Puppet : EventEmitter {
885884
}
886885
}
887886

887+
fun roomValidate(roomId: String): Future<Boolean> {
888+
return CompletableFuture.completedFuture(true)
889+
}
890+
891+
fun roomPayloadCache(roomId: String): RoomPayload? {
892+
return cacheRoomPayload.getIfPresent(roomId)
893+
}
894+
895+
896+
fun roomPayload(roomId: String): Future<RoomPayload> {
897+
return CompletableFuture.supplyAsync {
898+
return@supplyAsync cacheRoomPayload.get(roomId) { t: String ->
899+
val get = roomRawPayload(t).get()
900+
return@get roomRawPayloadParser(get).get()
901+
}
902+
}
903+
}
904+
905+
fun roomPayloadDirty(roomId: String): Future<Void> {
906+
cacheRoomPayload.invalidate(roomId)
907+
return CompletableFuture.completedFuture(null)
908+
}
909+
910+
888911
/**
889912
* Concat roomId & contactId to one string
890913
*/

wechaty/src/main/kotlin/io/github/wechaty/user/manager/ContactManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ContactManager(wechaty: Wechaty):Accessory(wechaty) {
6969
}
7070

7171
companion object {
72-
private val log = LoggerFactory.getLogger(Contact::class.java)
72+
private val log = LoggerFactory.getLogger(ContactManager::class.java)
7373
}
7474

7575

wechaty/src/main/kotlin/io/github/wechaty/user/manager/MessageManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class MessageManager (wechaty: Wechaty):Accessory(wechaty){
5656
}
5757

5858
companion object {
59-
private val log = LoggerFactory.getLogger(Contact::class.java)
59+
private val log = LoggerFactory.getLogger(MessageManager::class.java)
6060
}
6161

6262

wechaty/src/main/kotlin/io/github/wechaty/user/manager/RoomInvitationManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class RoomInvitationManager (wechaty: Wechaty):Accessory(wechaty){
1414
}
1515

1616
companion object {
17-
private val log = LoggerFactory.getLogger(Contact::class.java)
17+
private val log = LoggerFactory.getLogger(RoomInvitationManager::class.java)
1818
}
1919

2020
}

0 commit comments

Comments
 (0)