Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict channel invitations to non-guest accounts #90

Merged
merged 2 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ 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`
- **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.
- (Optional) **AttachmentMessage**: Message text in attachment containing user action buttons.
- (Optional) **Actions**: Use this to add new team members to channels automatically or based on which action button they pressed.
- **ActionType**: One of `button` or `automatic`. When `button`: enables uses to select which types of channels they want to join. When `automatic`: the user is automatically added to the specified channels.
Expand Down
3 changes: 3 additions & 0 deletions server/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type ConfigMessage struct {

// Number of seconds to wait before sending the message
DelayInSeconds int

// Whether or not to include guest users
IncludeGuests bool
}

// Configuration from config.json
Expand Down
3 changes: 3 additions & 0 deletions server/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func (p *Plugin) UserHasJoinedTeam(c *plugin.Context, teamMember *model.TeamMemb
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)
}
}
Expand Down