Beispiel #1
0
        private async Task ProcessMessageAsync(SQSEvent.SQSMessage message, Table skillsTable, IDBFacade db, ILambdaContext context)
        {
            Metrics.AddData(new MetricDatum
            {
                MetricName   = "IncomingJobPosts",
                Value        = 1,
                Unit         = StandardUnit.Count,
                TimestampUtc = DateTime.UtcNow,
                Dimensions   = new List <Dimension>
                {
                    new Dimension
                    {
                        Name  = "IncomingJobPosts",
                        Value = "1"
                    }
                }
            });

            SecretManager sm = new SecretManager();

            _webhook_url = sm.Get("SLACK_WEBHOOK");

            JObject       jobPost         = JObject.Parse(message.Body);
            string        jobPostHeader   = jobPost.Value <string>("header");
            string        jobPostUrl      = jobPost.Value <string>("sourceId");
            string        jobPostCustomer = jobPost.Value <string>("customer");
            List <string> jobPostKeywords = jobPost.Value <JArray>("keywords").ToObject <List <string> >();

            if (await SkillFilterExists(jobPostKeywords, skillsTable, db))
            {
                JObject jsonObject = await BuildSlackPayload(jobPostHeader, jobPostUrl, _closeApi, jobPostCustomer);

                await _client.PostAsJsonAsync(_webhook_url, jsonObject);

                Metrics.AddData(new MetricDatum
                {
                    MetricName   = "PostedJobPostsToSlack",
                    Value        = 1,
                    Unit         = StandardUnit.Count,
                    TimestampUtc = DateTime.UtcNow,
                    Dimensions   = new List <Dimension>
                    {
                        new Dimension
                        {
                            Name  = "PostedJobPostsToSlack",
                            Value = "1"
                        }
                    }
                });
            }

            await Task.CompletedTask;
        }
Beispiel #2
0
        private async Task ProcessMessageAsync(SQSEvent.SQSMessage message, ILambdaContext context)
        {
            SecretManager sm = new SecretManager();

            webhook_url = sm.Get("SLACK_WEBHOOK");

            JObject jobPost       = JObject.Parse(message.Body);
            string  jobPostHeader = jobPost.Value <string>("header");
            string  jobPostUrl    = jobPost.Value <string>("sourceId");

            JObject jsonObject = BuildSlackPayload(jobPostHeader, jobPostUrl);

            await client.PostAsJsonAsync(webhook_url, jsonObject);

            await Task.CompletedTask;
        }