From 251a5821bb590e7f71d68615b6d7cc4ebf124ca1 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 10 Dec 2015 23:58:58 +0000 Subject: Move URL to object attributes, add title --- .../blaears/controllers/GitMergeController.java | 11 ++++++----- .../uk/co/blatech/blaears/models/gitlab/Merge.java | 10 ---------- .../blaears/models/gitlab/ObjectAttributes.java | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 15 deletions(-) (limited to 'src/main/java/uk') diff --git a/src/main/java/uk/co/blatech/blaears/controllers/GitMergeController.java b/src/main/java/uk/co/blatech/blaears/controllers/GitMergeController.java index 8752401..b33b075 100644 --- a/src/main/java/uk/co/blatech/blaears/controllers/GitMergeController.java +++ b/src/main/java/uk/co/blatech/blaears/controllers/GitMergeController.java @@ -23,21 +23,22 @@ public class GitMergeController { try { String action = ""; - if (mergeMsg.getObjectKind().equals("open")) { + if (mergeMsg.getObjectAttributes().getAction().equals("open")) { action = " created a merge request from "; - } else if (mergeMsg.getObjectKind().equals("merge")) { + } else if (mergeMsg.getObjectAttributes().getAction().equals("merge")) { action = " merged from branch "; } else { - action = " did a " + mergeMsg.getObjectKind() + " from "; + action = " did a " + mergeMsg.getObjectAttributes().getAction() + " from "; // return "gitlab"; } String user = mergeMsg.getUser().getUsername(); String source = mergeMsg.getObjectAttributes().getSourceBranch(); String target = mergeMsg.getObjectAttributes().getTargetBranch(); - String url = mergeMsg.getUrl(); + String url = mergeMsg.getObjectAttributes().getUrl(); + String title = mergeMsg.getObjectAttributes().getUrl(); //DANGER - Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "echo theblueroom " + user + action + source + " to " + target + ": " + url + " | bash /home/smsd/msgrelay.bash "}); + Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "echo theblueroom " + user + action + source + " to " + target + ": [" + title + "] "+ url + " | bash /home/smsd/msgrelay.bash "}); model.addAttribute("result", "OK"); } catch (IOException e) { diff --git a/src/main/java/uk/co/blatech/blaears/models/gitlab/Merge.java b/src/main/java/uk/co/blatech/blaears/models/gitlab/Merge.java index 18c910d..ced162c 100644 --- a/src/main/java/uk/co/blatech/blaears/models/gitlab/Merge.java +++ b/src/main/java/uk/co/blatech/blaears/models/gitlab/Merge.java @@ -13,7 +13,6 @@ public class Merge { User user; @JsonProperty("object_attributes") ObjectAttributes objectAttributes; - String url; public String getObjectKind() { return objectKind; @@ -39,13 +38,4 @@ public class Merge { this.objectAttributes = objectAttributes; } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - } diff --git a/src/main/java/uk/co/blatech/blaears/models/gitlab/ObjectAttributes.java b/src/main/java/uk/co/blatech/blaears/models/gitlab/ObjectAttributes.java index 63bc758..9c3a0c3 100644 --- a/src/main/java/uk/co/blatech/blaears/models/gitlab/ObjectAttributes.java +++ b/src/main/java/uk/co/blatech/blaears/models/gitlab/ObjectAttributes.java @@ -16,6 +16,8 @@ public class ObjectAttributes { @JsonProperty("source_branch") String sourceBranch; String title; + String action; + String url; public int getId() { return id; @@ -48,4 +50,20 @@ public class ObjectAttributes { public void setTitle(String title) { this.title = title; } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } } -- cgit v1.2.3