/// <summary>
        /// !IMPORTANT! Call from the UI thread only.
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="user"></param>
        public void SaveSession(string sessionId, THPrivateUser user)
        {
            SessionId = sessionId;
            User      = user;

            _localStorage.Set(LocalStorageKeys.UserId, user.Id);
            _localStorage.Set(LocalStorageKeys.UserPassword, user.Password);

            OnUserChanged.SafeCall();
        }
 public static ConflictUser ToConflictUser(this THPrivateUser conflictUser)
 {
     return(new ConflictUser(
                publicProperties: conflictUser.PublicProperties,
                id: conflictUser.Id,
                displayName: conflictUser.DisplayName,
                avatarUrl: conflictUser.AvatarUrl,
                identities: IdentitiesToDictionary(conflictUser.Identities)
                ));
 }
 private void UpdateUser(THPrivateUser user, Action onSuccess, Action <GetSocialError> onFailure)
 {
     LogRequest("updateUser", user);
     WithHadesClient(client =>
     {
         User = client.updateUser(SessionId, user);
         Ui(() =>
         {
             LogResponse("updateUser", User);
             onSuccess.SafeCall();
         });
     }, onFailure);
 }
Example #4
0
 public static CurrentUser ToCurrentUser(this THPrivateUser currentUser)
 {
     return(new CurrentUser
     {
         PublicProperties = currentUser.PublicProperties,
         Id = currentUser.Id,
         Identities = IdentitiesToDictionary(currentUser.Identities),
         Verified = false,
         AvatarUrl = currentUser.AvatarUrl,
         DisplayName = currentUser.DisplayName,
         BanInfo = ConvertBanInfo(currentUser.InternalPrivateProperties),
         PrivateProperties = currentUser.PrivateProperties
     });
 }
        /// <summary>
        /// !IMPORTANT! Call from the UI thread only.
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="user"></param>
        public void SaveSession(string sessionId, THPrivateUser user, string uploadEndpoint)
        {
            SessionId = sessionId;
            User      = user.ToCurrentUser();

            _localStorage.Set(LocalStorageKeys.UserId, user.Id);
            _localStorage.Set(LocalStorageKeys.UserPassword, user.Password);

            foreach (var listener in _onUserChangesListeners)
            {
                listener.Listener.Invoke(User);
            }

            UploadEndpoint = uploadEndpoint;
        }
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.String)
                        {
                            SessionId = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.Struct)
                        {
                            User = new THPrivateUser();
                            User.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.I64)
                        {
                            ServerTime = iprot.ReadI64();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.Struct)
                        {
                            AppPlatformProperties = new THAppPlatformProperties();
                            AppPlatformProperties.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 5:
                        if (field.Type == TType.Bool)
                        {
                            FirstSession = iprot.ReadBool();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 6:
                        if (field.Type == TType.Struct)
                        {
                            ApplicationInfo = new THApplicationInfo();
                            ApplicationInfo.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 7:
                        if (field.Type == TType.String)
                        {
                            UploadEndpoint = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 8:
                        if (field.Type == TType.Struct)
                        {
                            UploadChunkSize = new THUploadChunkSize();
                            UploadChunkSize.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 9:
                        if (field.Type == TType.I64)
                        {
                            UploadFileSizeLimit = iprot.ReadI64();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 10:
                        if (field.Type == TType.String)
                        {
                            DeviceId = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }