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

[GH-42] Adds functionality to allows a team admin or system admin to adjust a dynamic team-welcome message #143

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

raghavaggarwal2308
Copy link

@raghavaggarwal2308 raghavaggarwal2308 commented Jul 23, 2024

Note: This PR contains all the changes from #81, we just fixed the review comments and merge conflicts here

Summary

This Pull Request adds new functionality that allows a team admin or system admin to adjust a dynamic team-welcome message. Previously, the only way a team message could be set was to adjust the config.json, and then redeploy the instance of mattermost. This has caused certain team admins over at Platform 1 to seek out a resolution that allows for the dynamic ability to set their team welcome message without adjusting the config.json.

With this new functionality, we have added 3 new slash commands that allow a user with the appropriate credentials to set, get, and delete what we are calling dynamic team messages with the following commands:

  • get_team_welcome - Grabs the stored dynamic team message (if it exists), or retrieves the config.json message set.
  • set_team_welcome [new message] - Stores internally a new KV pair where the key is the team id joined with the prefix: "teammsg_", and where the value is the message. This does not override the config.json value though.
  • delete_team_welcome - This deletes the KV pair set for the team without ever touching the config.json message (if it exists).

If a dynamic team message is found, then the get call will retrieve that first. If a user ever wanted to resort back to the config.json message, they will just need to delete the dynamic message. All values will defer to the config.json message if no dynamic message is found.

This new functionality also allows appropriate team admins to have access to the above slash commands, rather than permitting only system admins.

Also, on line 115, I fixed a misspelling of the word 'welcome.'

Please let me know if this is the direction you would like to pursue regarding the solution to issue 42! If there is anything that I left out of this PR, I would be more than happy to add that necessary information! Thank you!

Ticket Link

Fixes #42

@raghavaggarwal2308 raghavaggarwal2308 self-assigned this Jul 23, 2024
@raghavaggarwal2308 raghavaggarwal2308 mentioned this pull request Jul 23, 2024
server/command.go Outdated Show resolved Hide resolved
server/command.go Outdated Show resolved Hide resolved
server/command.go Outdated Show resolved Hide resolved
}
}

return ""
}

func (p *Plugin) validatePreviewPrivileges(teamID string, args *model.CommandArgs) (bool, error) {
if _, err := p.API.GetTeamMember(teamID, args.UserId); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we use p.client here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check everywhere

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ayusht2810 If we use p.client we will lose the access to status code, which is required here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated at other places

server/command.go Outdated Show resolved Hide resolved
server/command.go Outdated Show resolved Hide resolved
server/command.go Outdated Show resolved Hide resolved
server/command.go Outdated Show resolved Hide resolved
server/hooks.go Show resolved Hide resolved
server/hooks.go Outdated Show resolved Hide resolved
@raghavaggarwal2308
Copy link
Author

@ayusht2810 Fixed the comments added by you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to configure outside of the main config.json?
2 participants