From a4a10b47539aa1d72725a7ccee57d5799d4dcdfd Mon Sep 17 00:00:00 2001 From: Jason Frerich Date: Tue, 2 Aug 2022 02:42:08 -0500 Subject: [PATCH 1/9] Update CODEOWNERS (#94) --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index c1a612444..267712123 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @jfrerich +* @catalintomai From 95f1ba506402c90f9cf831472f46238adec2917a Mon Sep 17 00:00:00 2001 From: Spiros Economakis <812075+spirosoik@users.noreply.github.com> Date: Tue, 7 Feb 2023 11:25:06 +0200 Subject: [PATCH 2/9] Migrate from CircleCI to Github Actions (#98) CI/CD reusable workflows in Github Actions for Plugin software lifecycle Ticket: https://mattermost.atlassian.net/browse/CLD-4816 --- .circleci/config.yml | 63 ---------------------------------------- .github/workflows/cd.yml | 18 ++++++++++++ .github/workflows/ci.yml | 18 ++++++++++++ .nvmrc | 1 + lock-missing.txt | 1 + 5 files changed, 38 insertions(+), 63 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .nvmrc create mode 100644 lock-missing.txt diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 9e22b7125..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,63 +0,0 @@ -version: 2.1 - -orbs: - plugin-ci: mattermost/plugin-ci@volatile - -workflows: - version: 2 - nightly: - triggers: - - schedule: - cron: "0 0 * * *" - filters: - branches: - only: - - master - jobs: - - plugin-ci/lint - - plugin-ci/test - - plugin-ci/build - ci: - jobs: - - plugin-ci/lint: - filters: - tags: - only: /^v.*/ - - plugin-ci/test: - filters: - tags: - only: /^v.*/ - - plugin-ci/coverage: - filters: - tags: - only: /^v.*/ - requires: - - plugin-ci/test - - plugin-ci/build: - filters: - tags: - only: /^v.*/ - requires: - - plugin-ci/test - - plugin-ci/deploy-ci: - filters: - branches: - only: master - context: plugin-ci - requires: - - plugin-ci/lint - - plugin-ci/coverage - - plugin-ci/build - - plugin-ci/test - - plugin-ci/deploy-release-github: - filters: - tags: - only: /^v.*/ - branches: - ignore: /.*/ - context: matterbuild-github-token - requires: - - plugin-ci/lint - - plugin-ci/coverage - - plugin-ci/build - - plugin-ci/test diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 000000000..0268c8b1a --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,18 @@ +name: cd +on: + workflow_run: + workflows: ["ci"] + branches-ignore: ["*"] + types: + - completed + push: + tags: + - "^v.*" + +permissions: + contents: read + +jobs: + plugin-cd: + uses: mattermost/actions-workflows/.github/workflows/plugin-cd.yml@main + secrets: inherit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..4752d377f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: ci +on: + schedule: + - cron: "0 0 * * *" + push: + branches: + - master + tags: + - "^v.*" + pull_request: + +permissions: + contents: read + +jobs: + plugin-ci: + uses: mattermost/actions-workflows/.github/workflows/plugin-ci.yml@main + secrets: inherit diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..049c407af --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +14.21.1 diff --git a/lock-missing.txt b/lock-missing.txt new file mode 100644 index 000000000..0a99ab264 --- /dev/null +++ b/lock-missing.txt @@ -0,0 +1 @@ +mattermost-plugin-welcomebot From 72ddc654490f2f4f262b81783d59e6f1005cb513 Mon Sep 17 00:00:00 2001 From: kshitij katiyar <90389917+Kshitij-Katiyar@users.noreply.github.com> Date: Tue, 7 Feb 2023 17:29:20 +0530 Subject: [PATCH 3/9] [MI-2731]:Added additional Loggings for fixing issue #97 (#100) --- server/http_hooks.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/http_hooks.go b/server/http_hooks.go index 810ce08e9..6c632a7e2 100644 --- a/server/http_hooks.go +++ b/server/http_hooks.go @@ -13,6 +13,7 @@ import ( func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) { var action *Action if err := json.NewDecoder(r.Body).Decode(&action); err != nil || action == nil { + p.API.LogDebug("failed to decode action from request body", "error", err.Error()) p.encodeEphemeralMessage(w, "WelcomeBot Error: We could not decode the action") return } @@ -28,19 +29,19 @@ func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Req var err *model.AppError if data.User, err = p.API.GetUser(action.Context.UserID); err != nil { - p.API.LogError("failed to query user", "user_id", action.Context.UserID) + p.API.LogError("failed to query user", "user_id", action.Context.UserID, "error", err.Error()) p.encodeEphemeralMessage(w, "WelcomeBot Error: We could not find the supplied user") return } if data.Team, err = p.API.GetTeam(action.Context.TeamID); err != nil { - p.API.LogError("failed to query team", "team_id", action.Context.TeamID) + p.API.LogError("failed to query team", "team_id", action.Context.TeamID, "error", err.Error()) p.encodeEphemeralMessage(w, "WelcomeBot Error: We could not find the supplied team") return } if data.DirectMessage, err = p.API.GetDirectChannel(action.Context.UserID, p.botUserID); err != nil { - p.API.LogError("failed to query direct message channel", "user_id", action.Context.UserID) + p.API.LogError("failed to query direct message channel", "user_id", action.Context.UserID, "error", err.Error()) p.encodeEphemeralMessage(w, "WelcomeBot Error: We could not find the welcome bot direct message channel") return } @@ -49,7 +50,7 @@ func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Req // Check to make sure you're still in the team if teamMember, err := p.API.GetTeamMember(action.Context.TeamID, action.Context.UserID); err != nil || teamMember == nil || teamMember.DeleteAt > 0 { - p.API.LogError("Didn't have access to team", "user_id", action.Context.UserID, "team_id", action.Context.TeamID) + p.API.LogError("Didn't have access to team", "user_id", action.Context.UserID, "team_id", action.Context.TeamID, "error", err.Error()) p.encodeEphemeralMessage(w, "WelcomeBot Error: You do not appear to have access to this team") return } From a8589862317b9b1607a2f749dcc35ccb273189e9 Mon Sep 17 00:00:00 2001 From: Spiros Economakis <812075+spirosoik@users.noreply.github.com> Date: Tue, 7 Feb 2023 17:14:51 +0200 Subject: [PATCH 4/9] [skip ci] Remove lock missing txt (#101) --- lock-missing.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 lock-missing.txt diff --git a/lock-missing.txt b/lock-missing.txt deleted file mode 100644 index 0a99ab264..000000000 --- a/lock-missing.txt +++ /dev/null @@ -1 +0,0 @@ -mattermost-plugin-welcomebot From 90e8df9ccf421c1450081d632b2cefdf401529e2 Mon Sep 17 00:00:00 2001 From: Ben Schumacher Date: Thu, 30 Mar 2023 16:08:25 +0200 Subject: [PATCH 5/9] Fix regex for tags trigger in CI/CD (#104) --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0268c8b1a..c929fd9ba 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -7,7 +7,7 @@ on: - completed push: tags: - - "^v.*" + - "v*" permissions: contents: read diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4752d377f..3c05ae631 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: branches: - master tags: - - "^v.*" + - "v*" pull_request: permissions: From 98fd3241faccacff716eeedad67fa0229e19b902 Mon Sep 17 00:00:00 2001 From: Michael Kochell <6913320+mickmister@users.noreply.github.com> Date: Tue, 2 May 2023 15:29:52 -0400 Subject: [PATCH 6/9] Bump version to 1.3.0 (#105) * Bump version to 1.3.0 * make apply --- plugin.json | 4 ++-- server/manifest.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin.json b/plugin.json index a5e87f27e..b2fccaad8 100644 --- a/plugin.json +++ b/plugin.json @@ -4,8 +4,8 @@ "description": "This plugin adds a WelcomeBot that helps add new users to channels.", "homepage_url": "https://github.com/mattermost/mattermost-plugin-welcomebot", "support_url": "https://github.com/mattermost/mattermost-plugin-welcomebot/issues", - "release_notes_url": "https://github.com/mattermost/mattermost-plugin-welcomebot/releases/tag/v1.2.0", - "version": "1.2.0", + "release_notes_url": "https://github.com/mattermost/mattermost-plugin-welcomebot/releases/tag/v1.3.0", + "version": "1.3.0", "min_server_version": "5.37.0", "server": { "executables": { diff --git a/server/manifest.go b/server/manifest.go index 38e43ab9c..99642bdb0 100644 --- a/server/manifest.go +++ b/server/manifest.go @@ -7,5 +7,5 @@ var manifest = struct { Version string }{ ID: "com.mattermost.welcomebot", - Version: "1.2.0", + Version: "1.3.0", } From 002ffd4df9455c04382b4775b2b0c03ee15b1d18 Mon Sep 17 00:00:00 2001 From: Michael Kochell <6913320+mickmister@users.noreply.github.com> Date: Thu, 4 May 2023 16:49:18 -0400 Subject: [PATCH 7/9] Update CODEOWNERS (#106) * Update CODEOWNERS * remove old maintainers from readme --- CODEOWNERS | 2 +- README.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index 267712123..c11eb6ad4 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @catalintomai +* @mickmister diff --git a/README.md b/README.md index 33b0dfacb..fbdf38627 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,7 @@ [![Release](https://img.shields.io/github/v/release/mattermost/mattermost-plugin-welcomebot)](https://github.com/mattermost/mattermost-plugin-welcomebot/releases/latest) [![HW](https://img.shields.io/github/issues/mattermost/mattermost-plugin-welcomebot/Up%20For%20Grabs?color=dark%20green&label=Help%20Wanted)](https://github.com/mattermost/mattermost-plugin-welcomebot/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Up+For+Grabs%22+label%3A%22Help+Wanted%22) -**Maintainer:** [@jfrerich](https://github.com/jfrerich) -**Co-Maintainer:** [@iomodo](https://github.com/iomodo) +**Maintainer:** [@mickmister](https://github.com/mickmister) Use this plugin to improve onboarding and HR processes. It adds a Welcome Bot that helps welcome users to teams and/or channels as well as easily join channels based on selections. From f982137e54573a5081794d65425669f7869f1c48 Mon Sep 17 00:00:00 2001 From: Michael Kochell <6913320+mickmister@users.noreply.github.com> Date: Wed, 10 May 2023 11:54:44 -0400 Subject: [PATCH 8/9] Revert #82 and #79 (#109) * Revert "solves Gh 72 - Welcome bot will not let me add a message to private channels (#79)" This reverts commit 517c73ef776bac891c2053c77f7bc52b39bca950. * Revert "[mm-65] Allows users to add multiple teams to the messages using `team-a,team-b` in the messages (#82)" This reverts commit 03ea7221a9a3976de876f8c8801c3ebb0fa9509f. --- README.md | 6 +++--- server/command.go | 18 +++++++----------- server/hooks.go | 16 ++++++---------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index fbdf38627..d2cd8f14f 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ To configure the Welcome Bot, edit your `config.json` file with a message you wa "com.mattermost.welcomebot": { "WelcomeMessages": [ { - "TeamName": "your-team-name, your-second-team-name", + "TeamName": "your-team-name", "DelayInSeconds": 3, "Message": [ "Your welcome message here. Each list item specifies one line in the message text." @@ -62,7 +62,7 @@ To configure the Welcome Bot, edit your `config.json` file with a message you wa where -- **TeamName**: The teams for which the Welcome Bot sends a message. Must be the team handle used in the URL, in lowercase. For example, in the following URL, the **TeamName** value is `my-team`: https://example.com/my-team/channels/my-channel . In the case of multiple teams, use comma separated fields. For example `"my-team, my-team-2"` to display the same messages for both `my-team` and `my-team-2` +- **TeamName**: The team for which the Welcome Bot sends a message for. Must be the team handle used in the URL, in lowercase. For example, in the following URL the **TeamName** value is `my-team`: https://example.com/my-team/channels/my-channel - **DelayInSeconds**: The number of seconds after joining a team that the user receives a welcome message. - **Message**: The message posted to the user. - (Optional) **IncludeGuests**: Whether or not to include guest users. @@ -100,7 +100,7 @@ To accomplish the above, you can specify the following configuration in your `co "com.mattermost.welcomebot": { "WelcomeMessages": [ { - "TeamName": "staff, management", + "TeamName": "staff", "DelayInSeconds": 5, "Message": [ "### Welcome {{.UserDisplayName}} to the Staff {{.Team.DisplayName}} team!", diff --git a/server/command.go b/server/command.go index 9ce161756..281fce0e0 100644 --- a/server/command.go +++ b/server/command.go @@ -86,17 +86,13 @@ func (p *Plugin) validateCommand(action string, parameters []string) string { func (p *Plugin) executeCommandPreview(teamName string, args *model.CommandArgs) { found := false for _, message := range p.getWelcomeMessages() { - var teamNamesArr = strings.Split(message.TeamName, ",") - for _, name := range teamNamesArr { - tn := strings.TrimSpace(name) - if tn == teamName { - p.postCommandResponse(args, "%s", teamName) - if err := p.previewWelcomeMessage(teamName, args, *message); err != nil { - p.postCommandResponse(args, "error occurred while processing greeting for team `%s`: `%s`", teamName, err) - return - } - found = true + if message.TeamName == teamName { + if err := p.previewWelcomeMessage(teamName, args, *message); err != nil { + p.postCommandResponse(args, "error occurred while processing greeting for team `%s`: `%s`", teamName, err) + return } + + found = true } } @@ -134,7 +130,7 @@ func (p *Plugin) executeCommandSetWelcome(args *model.CommandArgs) { return } - if channelInfo.Type == model.ChannelTypeDirect { + if channelInfo.Type == model.ChannelTypePrivate { p.postCommandResponse(args, "welcome messages are not supported for direct channels") return } diff --git a/server/hooks.go b/server/hooks.go index e1f7efe1c..25b1b744e 100644 --- a/server/hooks.go +++ b/server/hooks.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "strings" "time" "github.com/mattermost/mattermost-server/v6/model" @@ -19,15 +18,12 @@ func (p *Plugin) UserHasJoinedTeam(c *plugin.Context, teamMember *model.TeamMemb } for _, message := range p.getWelcomeMessages() { - var teamNamesArr = strings.Split(message.TeamName, ",") - for _, name := range teamNamesArr { - tn := strings.TrimSpace(name) - if tn == data.Team.Name { - if data.User.IsGuest() && !message.IncludeGuests { - continue - } - go p.processWelcomeMessage(*data, *message) - } + if data.User.IsGuest() && !message.IncludeGuests { + continue + } + + if message.TeamName == data.Team.Name { + go p.processWelcomeMessage(*data, *message) } } } From 344cddfb57051d2d05b874bd0b3d4e415272ad55 Mon Sep 17 00:00:00 2001 From: Michael Kochell <6913320+mickmister@users.noreply.github.com> Date: Thu, 11 May 2023 13:35:27 -0400 Subject: [PATCH 9/9] add to readme IncludeGuests setting (#115) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d2cd8f14f..3fbd535f1 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ To configure the Welcome Bot, edit your `config.json` file with a message you wa { "TeamName": "your-team-name", "DelayInSeconds": 3, + "IncludeGuests": false, "Message": [ "Your welcome message here. Each list item specifies one line in the message text." ],