示例#1
0
        public IActionResult Follow([FromRoute] Guid account_id, [FromRoute] Guid repository_id)
        {
            try
            {
                JwtClaimM jwt_claim = _jwtAuth.GetClaims(Request);
                _repository.EnsureExisted(jwt_claim.UserId, account_id, repository_id);
                if (_repository.HasHook(repository_id))
                {
                    return(Ok());
                }

                dynamic token   = _repository.GetToken(repository_id);
                int     hook_id = _gHWebhook.Create(token.Userame, token.RepositoryName, token.AccessToken);
                _repository.SetHook(repository_id, hook_id.ToString());

                string           default_branch_name = _gHRepository.Get(token.Userame, token.RepositoryName, token.AccessToken).Default_branch;
                IList <GHBranch> branches;
                int page = 1;

                do
                {
                    branches = _gHBranch.GetBranches(token.Userame, token.RepositoryName, token.AccessToken, page++);
                    _branch.AddMany(branches, repository_id, default_branch_name);
                } while (branches.Count >= 100);

                return(Ok());
            }
            catch (Exception e)
            {
                return(GetError(e));
            }
        }