@@ -18,6 +18,7 @@ import io.github.wechaty.memorycard.MemoryCard
1818import io.github.wechaty.schemas.*
1919import io.github.wechaty.utils.FutureUtils
2020import io.github.wechaty.utils.JsonUtils
21+ import okhttp3.internal.toImmutableList
2122import org.apache.commons.collections4.CollectionUtils
2223import org.apache.commons.lang3.StringUtils
2324import 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 */
0 commit comments