Example #1
0
        public async Task <UserDetail> GetUserDetail(string userId)
        {
            var detail = await ContextActionWithPageAccessWaitAsync(async context =>
            {
                return(await context.User.GetUserDetail(userId));
            });

            var owner = NicoVideoOwnerDb.Get(userId);

            if (detail != null)
            {
                if (owner == null)
                {
                    owner = new NicoVideoOwner()
                    {
                        OwnerId  = userId,
                        UserType = UserType.User
                    };
                }
                owner.ScreenName = detail.Nickname;
                owner.IconUrl    = detail.ThumbnailUri;


                NicoVideoOwnerDb.AddOrUpdate(owner);
            }

            return(detail);
        }
Example #2
0
        public async Task <NicoVideoOwner> GetUser(string userId)
        {
            using (var releaser = await _NicoPageAccessLock.LockAsync())
            {
                var userRes = await ConnectionRetryUtil.TaskWithRetry(() =>
                {
                    return(Context.User.GetUserAsync(userId));
                });

                var owner = NicoVideoOwnerDb.Get(userId);
                if (userRes.Status == "ok")
                {
                    var user = userRes.User;
                    if (owner == null)
                    {
                        owner = new NicoVideoOwner()
                        {
                            OwnerId  = userId,
                            UserType = UserType.User
                        };
                    }
                    owner.ScreenName = user.Nickname;
                    owner.IconUrl    = user.ThumbnailUrl;

                    NicoVideoOwnerDb.AddOrUpdate(owner);
                }

                return(owner);
            }
        }
Example #3
0
        public async Task <NicoVideoOwner> GetUser(string userId)
        {
            var userRes = await ContextActionWithPageAccessWaitAsync(async context =>
            {
                return(await context.User.GetUserAsync(userId));
            });

            var owner = NicoVideoOwnerDb.Get(userId);

            if (userRes.Status == "ok")
            {
                var user = userRes.User;
                if (owner == null)
                {
                    owner = new NicoVideoOwner()
                    {
                        OwnerId  = userId,
                        UserType = UserType.User
                    };
                }
                owner.ScreenName = user.Nickname;
                owner.IconUrl    = user.ThumbnailUrl;

                NicoVideoOwnerDb.AddOrUpdate(owner);
            }

            return(owner);
        }
Example #4
0
        public async Task <UserDetail> GetUserDetail(string userId)
        {
            var userDetail = await ConnectionRetryUtil.TaskWithRetry(() =>
            {
                return(Context.User.GetUserDetail(userId));
            });

            if (userDetail != null)
            {
                var owner = NicoVideoOwnerDb.Get(userId);
                if (owner == null)
                {
                    owner = new NicoVideoOwner()
                    {
                        OwnerId  = userId,
                        UserType = UserType.User
                    };
                }
                owner.ScreenName = userDetail.Nickname;
                owner.IconUrl    = userDetail.ThumbnailUri;

                NicoVideoOwnerDb.AddOrUpdate(owner);
            }

            return(userDetail);
        }