Exemplo n.º 1
0
        public async Task <RoomInvitationPayload> RoomInvitationRawPayload(string id)
        {
            var payload = new RoomInvitationPayload();
            var request = new RoomInvitationPayloadRequest()
            {
                Id = id
            };
            var response = await grpcClient.RoomInvitationPayloadAsync(request);

            if (response == null)
            {
                payload = new RoomInvitationPayload()
                {
                    Avatar       = response.Avatar,
                    Id           = response.Id,
                    Invitation   = response.Invitation,
                    InviterId    = response.InviterId,
                    MemberCount  = response.MemberCount,
                    MemberIdList = response.MemberIds.ToList(),
                    ReceiverId   = response.ReceiverId,
                    Timestamp    = (long)response.Timestamp,
                    Topic        = response.Topic
                };
            }
            return(payload);
        }
Exemplo n.º 2
0
        public async Task <RoomInvitation> FromJson(RoomInvitationPayload payload)
        {
            if (Logger.IsEnabled(LogLevel.Trace))
            {
                Logger.LogTrace($"fromJson({JsonConvert.SerializeObject(payload)})");
            }
            await Puppet.SetRoomInvitationPayload(payload.Id, payload);

            return(WechatyInstance.RoomInvitation.Load(payload.Id));
        }
        private async Task <RoomInvitationPayload> GetRoomInvitationPayload(string roomId)
        {
            Payload = await _cacheRoomInvitationPayload.GetOrAddAsync(roomId,
                                                                      async() => _puppetService.RoomInvitationRawPayloadParser(await _puppetService.RoomInvitationRawPayload(roomId)),
                                                                      () => new DistributedCacheEntryOptions()
            {
                AbsoluteExpiration = DateTimeOffset.Now.AddSeconds(CacheConst.CacheGlobalExpirationTime)
            });

            return(Payload);
        }
Exemplo n.º 4
0
 public RoomInvitationPayload RoomInvitationRawPayloadParser(RoomInvitationPayload payload)
 {
     return(payload);
 }
 protected override async Task <RoomInvitationPayload> RoomInvitationRawPayloadParser(RoomInvitationPayload rawPayload)
 {
     return(_ = rawPayload);
 }
Exemplo n.º 6
0
        /// <summary>
        /// set room inviatation payload
        /// </summary>
        /// <param name="roomInvitationId"></param>
        /// <param name="newPayload"></param>
        /// <returns></returns>
#pragma warning disable CS1998 // 异步方法缺少 "await" 运算符,将以同步方式运行
        public async Task SetRoomInvitationPayload(string roomInvitationId, RoomInvitationPayload newPayload) => CacheRoomInvitationPayload.Set(roomInvitationId, newPayload);
Exemplo n.º 7
0
 protected abstract Task <RoomInvitationPayload> RoomInvitationRawPayloadParser(RoomInvitationPayload rawPayload);