~girishm/op-mattermost

a74d05dc3aa656b133694ac8b5c30e208f2edf52 — girishm 2 months ago 3171b9a
what's there in a name?
3 files changed, 14 insertions(+), 5 deletions(-)

M resource/routes.js
M resource/uiActions.js
M resource/util.js
M resource/routes.js => resource/routes.js +1 -1
@@ 37,7 37,7 @@ module.exports = (app, axios) => {
    if(token === process.env.MATTERMOST_SLASH_TOKEN) {
      console.log("Request Body to / ", JSON.stringify(req.body, null, 2));
      if(command === "/op") {
        uiActions.showMenuBtn(req, res);
        uiActions.showMenuBtn(req, res, axios);
      }
      else {
        res.send("*I don't understand ", command, ". Let's try again...* \n `/op`").status(500);

M resource/uiActions.js => resource/uiActions.js +11 -2
@@ 36,6 36,7 @@ class UIactions {
      username: 'apikey',
      password: process.env.OP_ACCESS_TOKEN
    }
    this.currentUser = '';
  }

  showSelProject(req, res, axios, action) {


@@ 435,8 436,16 @@ class UIactions {
    });
  }

  showMenuBtn(req, res) {
    res.set('Content-Type', 'application/json').send(JSON.stringify(this.util.getMenuBtnJSON(this.intURL))).status(200);
  showMenuBtn(req, res, axios) {
    axios({
      url: '/users/me',
      method: 'get',
      baseURL: this.opURL,
      auth: this.opAuth
    }).then((response) => {
      this.currentUser = response.data.firstName;
      res.set('Content-Type', 'application/json').send(JSON.stringify(this.util.getMenuBtnJSON(this.intURL, this.currentUser))).status(200);
    });
  }
}
module.exports = UIactions;
\ No newline at end of file

M resource/util.js => resource/util.js +2 -2
@@ 353,13 353,13 @@ class Util {
    };
  }

  getMenuBtnJSON(url) {
  getMenuBtnJSON(url, firstName) {
    return {
      "response_type": "in_channel",
      "props": {
        "attachments": [
          {
            "pretext": "Hello :)",
            "pretext": "Hello " + firstName + " :)",
            "text": "What would you like me to do?",
            "actions": [
              {