예제 #1
0
        public async Task <HttpResponseMessage> Post(string id)
        {
            Watch project = await _watchProjectService.GetByIdAsync(id, UserId);

            // Add to statistics in background
            Task.Run(() => _cassandraStatisticsService.AddAbuseAsync(StatisticsSpaces.Projects, id, UserId))
            .ContinueWith(r => _projectService.IncrementAbuseCounterAsync(id), TaskContinuationOptions.OnlyOnRanToCompletion).NoWarning();

            // Send activation e-mail
            try
            {
                DomainUser reporter = await _userService.GetAsync(UserId);

                await _emailNotificationService.SendAbuseNotificationAsync(project, reporter);
            }
            catch (Exception e)
            {
                Trace.TraceError("Failed to send abuse report e-mail from user {0}: {1}", UserId, e);
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }