From af738f58fc7e0af5418b3c929c65801c3f9a6913 Mon Sep 17 00:00:00 2001 From: Wolfgang Apolinarski Date: Wed, 26 Jul 2017 22:28:34 +0200 Subject: [PATCH] Added more documentation, more error messages and an example configuration --- README.md | 12 ++++++ pom.xml | 3 ++ src/assembly/bin.xml | 40 +++++++++++++++++++ .../tools/slack/mail2slack/GmailServer.java | 4 ++ src/main/resources/settings.sample.conf | 29 ++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 src/assembly/bin.xml create mode 100644 src/main/resources/settings.sample.conf diff --git a/README.md b/README.md index 551d33e..f48d935 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ # Mail2Slack A small service that sends e-mails to slack. + +## Requirements + * Currently only supports Gmail. + +## Build Requirements + * Java 8 + * Maven + +## Configuration +See src/main/resources/settings.sample.conf for an example configuration file. +## Other +New features (individual icons, more configuration settings) will be added gradually. \ No newline at end of file diff --git a/pom.xml b/pom.xml index e9085fc..77663ab 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,9 @@ maven-assembly-plugin 3.0.0 + + src/assembly/bin.xml + jar-with-dependencies diff --git a/src/assembly/bin.xml b/src/assembly/bin.xml new file mode 100644 index 0000000..0fabfab --- /dev/null +++ b/src/assembly/bin.xml @@ -0,0 +1,40 @@ + +release + + tar.gz + zip + + + + + + README* + pom.xml + + + + target/classes + bin + + **/*.class + /*.sample.conf + + + + src/main/java + src + + **/*.java + + + + target + lib + + Mail2Slack-*SNAPSHOT.jar + + + + \ No newline at end of file diff --git a/src/main/java/de/apolinarski/tools/slack/mail2slack/GmailServer.java b/src/main/java/de/apolinarski/tools/slack/mail2slack/GmailServer.java index 91c7f84..a882f31 100644 --- a/src/main/java/de/apolinarski/tools/slack/mail2slack/GmailServer.java +++ b/src/main/java/de/apolinarski/tools/slack/mail2slack/GmailServer.java @@ -54,6 +54,7 @@ public void readAndPost() LocalDate maxDate = date.plusDays(settings.getDeleteOldMesagesDays()); if(LocalDate.now().isAfter(maxDate)) { + System.err.println("Deleted mail that is older than 14 days."); message.setFlag(Flag.DELETED, true); } continue; @@ -61,6 +62,7 @@ public void readAndPost() String channel = extractChannel(message.getSubject()); if(channel==null) { + System.err.println("Channel is invalid: "+message.getSubject()); message.setFlag(Flag.DELETED, true); continue; } @@ -71,6 +73,7 @@ public void readAndPost() InternetAddress[] userNameAddress=(InternetAddress[]) message.getFrom(); if(userNameAddress==null || userNameAddress.length==0 || userNameAddress[0]==null) { + System.err.println("No valid user name address!"); message.setFlag(Flag.DELETED, true); continue; } @@ -81,6 +84,7 @@ public void readAndPost() userName = userNameAddress[0].getAddress(); if(userName==null) { + System.err.println("No valid user name!"); message.setFlag(Flag.DELETED, true); continue; } diff --git a/src/main/resources/settings.sample.conf b/src/main/resources/settings.sample.conf new file mode 100644 index 0000000..678bbb7 --- /dev/null +++ b/src/main/resources/settings.sample.conf @@ -0,0 +1,29 @@ +# This is a configuration file for the Mail2Slack server application + + +# SECURITY = [STARTTLS|TLS|NONE] +SECURITY = STARTTLS + +# USERNAME = me@example.com +# PASSWORD = + +# RELEVANT-FOLDER - the folder that should be searched for new messages +RELEVANT-FOLDER = inbox + +# DELETE-OLD-MESSAGES-AFTER-DAYS = [|0|-1] +DELETE-OLD-MESSAGES-AFTER-DAYS = 14 + +# IMAP-Settings: +# IMAP-SERVER = imap.example.com +IMAP-SERVER = imap.gmail.com + +# IMAP-PROTOCOL = [IMAPS] +IMAP-PROTOCOL = IMAPS + +# Settings that are not used: +# SMTP-SERVER = smtp.example.com +SMTP-SERVER = smtp.gmail.com +# SMTP-PORT = +SMTP-PORT = 587 + +SLACK-HOOK-URL = https://hooks.slack.com/services/