public void Any(SyncSingleUser request)
        {
            if (request.UserId == null)
            {
                throw new HttpError(400, "BadRequest");
            }

            GetUserByIdResponse user;

            try
            {
                user = DiscourseClient.GetUserById(request.UserId);
            }
            catch (Exception e)
            {
                Log.Error("Failed to get user from Discourse - {0}".Fmt(e.Message), e);
                throw new HttpError(500, "Failed to get user from Discourse");
            }

            if (user == null)
            {
                throw HttpError.NotFound("User not found in Discourse");
            }
            // Email is ONLY populated when performing admin get all users as Discourse API allows it via show_emails
            // query string. Single user request doesn't have same rules..
            var emailResponse = DiscourseClient.GetUserEmail(request.UserId);

            user.User.Email = emailResponse.Email;

            var serviceStackSubscription = GetDiscourseUserServiceStackSubscription(user.User);

            UpdateDiscourseAccountStatus(user.User, serviceStackSubscription, 1000);
        }
Ejemplo n.º 2
0
        public void TestSyncSingleAccount()
        {
            var service = appHost.Resolve <SyncAccountServices>();
            var req     = new SyncSingleUser {
                UserId = "layoric"
            };

            service.Any(req);
            var discourseClient = appHost.Resolve <IDiscourseClient>() as MockDiscourseClient;

            Assert.That(discourseClient.ApproveCalledCount > 0);
        }