-
Notifications
You must be signed in to change notification settings - Fork 58
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
MM-17818 Adding API for adding/replacing links. #85
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 big requests:
- reconsider subpackage naming
- support batch updates of links, maybe later add List/Delete
|
I'm generally ok with the ^^, but I am concerned about what happens on community when you update the config? (all plugins on all servers are notified, each time). Agree that KV is the best answer. |
Going to do that as a follow up ticket: https://mattermost.atlassian.net/browse/MM-22001 |
for i := range links { | ||
if links[i].Name == newLink.Name || links[i].Pattern == newLink.Pattern { | ||
links[i] = newLink | ||
found = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Was wondering how/where the uniqueness is checked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On that note, @crspeller we should not be saving what hasn't changed. I think it's just too wasteful, TBH. Add (content) de=duplication, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added #88
so, is this where we left it?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one last request to consider - avoid saving if nothing changed?
for i := range links { | ||
if links[i].Name == newLink.Name || links[i].Pattern == newLink.Pattern { | ||
links[i] = newLink | ||
found = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On that note, @crspeller we should not be saving what hasn't changed. I think it's just too wasteful, TBH. Add (content) de=duplication, maybe?
@levb Fixed the issue where duplicates where being saved anyway. Also you convinced me that the header way is better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with the caveat of #88
server/api/api.go
Outdated
ifPluginId := r.Context().Value(PluginIDContextValue) | ||
pluginId, ok := ifPluginId.(string) | ||
if ok && pluginId != "" { | ||
pluginId := r.Header.Get("Mattermost-Plugin-ID") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
for i := range links { | ||
if links[i].Name == newLink.Name || links[i].Pattern == newLink.Pattern { | ||
links[i] = newLink | ||
found = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added #88
* check for "no change" * fixed an error treating empty UserID * minor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am having issues building this locally even after getting the branch for the corresponding functionality in the other repo.
Please merge and I will test from master and create follow-up issues as needed.
Summary
Adds an API route for replacing links. Some refactoring into packages to facilitate testing and easy imports for clients.
Example of use in JIRA PR: mattermost/mattermost-plugin-jira#453