Skip to content

Commit

Permalink
Revert "Revert "do not try to send slack notification if no webhook u…
Browse files Browse the repository at this point in the history
…rl""

This reverts commit 6220573.
  • Loading branch information
ufuk committed Oct 15, 2017
1 parent 6220573 commit 4324392
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/expercise/domain/user/User.java
Expand Up @@ -13,7 +13,8 @@
import java.util.List;

@Entity
@SequenceGenerator(name = "ID_GENERATOR", sequenceName = "SEQ_USER")
@Table(name = "USERS")
@SequenceGenerator(name = "ID_GENERATOR", sequenceName = "SEQ_USERS")
public class User extends BaseEntity {

private String firstName;
Expand Down
@@ -1,6 +1,7 @@
package com.expercise.service.notification;

import com.expercise.service.configuration.ConfigurationService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -21,13 +22,20 @@ public class SlackNotificationService {

@Async
public void sendMessage(SlackMessage slackMessage) {
String slackIncomingWebhookUrl = configurationService.getSlackIncomingWebhookUrl();

if (StringUtils.isBlank(slackIncomingWebhookUrl)) {
LOGGER.warn("No slack incoming webhook url configured!");
return;
}

try {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("Content-type", MediaType.APPLICATION_JSON_VALUE + "; charset=utf-8");

HttpEntity<SlackMessage> httpEntity = new HttpEntity<>(slackMessage, httpHeaders);

new RestTemplate().postForLocation(configurationService.getSlackIncomingWebhookUrl(), httpEntity);
new RestTemplate().postForLocation(slackIncomingWebhookUrl, httpEntity);
} catch (Exception e) {
LOGGER.error("Slack notification couldn't sent: " + slackMessage, e);
}
Expand Down
15 changes: 6 additions & 9 deletions src/main/resources/application.properties
Expand Up @@ -2,15 +2,12 @@
# Spring Boot #
###############
spring.profiles.active=dev
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.generate-ddl=true
spring.datasource.platform=H2
spring.datasource.url=jdbc:h2:mem:dolap:H2;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS PUBLIC
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.initialize=true
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:postgresql://localhost:5432/codingexpercise
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.username=postgres
spring.datasource.password=.

####################
# Coding Expercise #
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/messages_en.properties
Expand Up @@ -121,6 +121,7 @@ label.lastName = Last Name
label.lingo = Lingo
label.lingo.tr = Turkish
label.lingo.en = English
label.lingo.pt = Portuguese
label.menu = Welcome to expercise
label.menu.addNewChallenge = Add New Challenge
label.menu.manageChallenges = Manage Challenges
Expand Down Expand Up @@ -217,6 +218,7 @@ whatIsExpercise.free.text = Now and forever.
###########
English = English
Turkish = Turkish
Portuguese = Portuguese

Integer = Integer
Text = Text
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/messages_pt.properties
Expand Up @@ -121,6 +121,7 @@ label.lastName = Last Name
label.lingo = Lingo
label.lingo.tr = Turkish
label.lingo.en = English
label.lingo.pt = Portuguese
label.menu = Welcome to expercise
label.menu.addNewChallenge = Add New Challenge
label.menu.manageChallenges = Manage Challenges
Expand Down Expand Up @@ -217,6 +218,7 @@ whatIsExpercise.free.text = Now and forever.
###########
English = English
Turkish = Turkish
Portuguese = Portuguese

Integer = Integer
Text = Text
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/messages_tr.properties
Expand Up @@ -122,6 +122,7 @@ label.lastName = Soyad
label.lingo = Arayüz Dili
label.lingo.tr = Türkçe
label.lingo.en = İngilizce
label.lingo.pt = Portekizce
label.menu = expercise'a Hoşgeldiniz
label.menu.addNewChallenge = Yeni Zorlu Görev Ekle
label.menu.manageChallenges = Zorlu Görevleri Yönet
Expand Down Expand Up @@ -217,6 +218,7 @@ whatIsExpercise.free.text = Şimdi ve sonsuza dek.
###########
English = İngilizce
Turkish = Türkçe
Portuguese = Portekizce

Integer = Tamsayı
Text = Metin
Expand Down

0 comments on commit 4324392

Please sign in to comment.