Skip to content

Commit f982137

Browse files
authored
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 517c73e. * Revert "[mm-65] Allows users to add multiple teams to the messages using `team-a,team-b` in the messages (#82)" This reverts commit 03ea722.
1 parent 002ffd4 commit f982137

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To configure the Welcome Bot, edit your `config.json` file with a message you wa
3131
"com.mattermost.welcomebot": {
3232
"WelcomeMessages": [
3333
{
34-
"TeamName": "your-team-name, your-second-team-name",
34+
"TeamName": "your-team-name",
3535
"DelayInSeconds": 3,
3636
"Message": [
3737
"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
6262

6363
where
6464

65-
- **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`
65+
- **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
6666
- **DelayInSeconds**: The number of seconds after joining a team that the user receives a welcome message.
6767
- **Message**: The message posted to the user.
6868
- (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
100100
"com.mattermost.welcomebot": {
101101
"WelcomeMessages": [
102102
{
103-
"TeamName": "staff, management",
103+
"TeamName": "staff",
104104
"DelayInSeconds": 5,
105105
"Message": [
106106
"### Welcome {{.UserDisplayName}} to the Staff {{.Team.DisplayName}} team!",

server/command.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,13 @@ func (p *Plugin) validateCommand(action string, parameters []string) string {
8686
func (p *Plugin) executeCommandPreview(teamName string, args *model.CommandArgs) {
8787
found := false
8888
for _, message := range p.getWelcomeMessages() {
89-
var teamNamesArr = strings.Split(message.TeamName, ",")
90-
for _, name := range teamNamesArr {
91-
tn := strings.TrimSpace(name)
92-
if tn == teamName {
93-
p.postCommandResponse(args, "%s", teamName)
94-
if err := p.previewWelcomeMessage(teamName, args, *message); err != nil {
95-
p.postCommandResponse(args, "error occurred while processing greeting for team `%s`: `%s`", teamName, err)
96-
return
97-
}
98-
found = true
89+
if message.TeamName == teamName {
90+
if err := p.previewWelcomeMessage(teamName, args, *message); err != nil {
91+
p.postCommandResponse(args, "error occurred while processing greeting for team `%s`: `%s`", teamName, err)
92+
return
9993
}
94+
95+
found = true
10096
}
10197
}
10298

@@ -134,7 +130,7 @@ func (p *Plugin) executeCommandSetWelcome(args *model.CommandArgs) {
134130
return
135131
}
136132

137-
if channelInfo.Type == model.ChannelTypeDirect {
133+
if channelInfo.Type == model.ChannelTypePrivate {
138134
p.postCommandResponse(args, "welcome messages are not supported for direct channels")
139135
return
140136
}

server/hooks.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"fmt"
5-
"strings"
65
"time"
76

87
"github.com/mattermost/mattermost-server/v6/model"
@@ -19,15 +18,12 @@ func (p *Plugin) UserHasJoinedTeam(c *plugin.Context, teamMember *model.TeamMemb
1918
}
2019

2120
for _, message := range p.getWelcomeMessages() {
22-
var teamNamesArr = strings.Split(message.TeamName, ",")
23-
for _, name := range teamNamesArr {
24-
tn := strings.TrimSpace(name)
25-
if tn == data.Team.Name {
26-
if data.User.IsGuest() && !message.IncludeGuests {
27-
continue
28-
}
29-
go p.processWelcomeMessage(*data, *message)
30-
}
21+
if data.User.IsGuest() && !message.IncludeGuests {
22+
continue
23+
}
24+
25+
if message.TeamName == data.Team.Name {
26+
go p.processWelcomeMessage(*data, *message)
3127
}
3228
}
3329
}

0 commit comments

Comments
 (0)