Verified Commit d5c94d6f authored by j's avatar j
Browse files

Also block channel updates

parent 274f6ac9
......@@ -2,7 +2,7 @@
"id": "mattermost-great-filter",
"name": "The Great Filter",
"description": "For filtering out messages",
"version": "0.1.2",
"version": "0.1.3",
"server": {
"executables": {
"linux-amd64": "server/dist/plugin-linux-amd64",
......@@ -26,6 +26,14 @@
"help_text": "A list of allowed users",
"placeholder": "redfast00",
"default": "redfast00"
},
{
"key": "ChannelNoUpdate",
"display_name": "Channels to block channel header updates in, separated by spaces",
"type": "text",
"help_text": "A list of channels not to update",
"placeholder": "mumble",
"default": "mumble"
}
],
"header": "",
......
......@@ -5,5 +5,5 @@ var manifest = struct {
Version string
}{
Id: "mattermost-great-filter",
Version: "0.1.2",
Version: "0.1.3",
}
......@@ -12,8 +12,9 @@ import (
type Plugin struct {
plugin.MattermostPlugin
Channel string
AllowedUsers string
Channel string
AllowedUsers string
ChannelNoUpdate string
}
func main() {
......@@ -38,6 +39,15 @@ func (p *Plugin) FilterPost(post *model.Post) (*model.Post, string) {
p.API.LogError("Failed to find channel in post")
return nil, ""
}
if strings.Contains(post.Message, "updated the channel header") {
noUpdateChannels := strings.Split(p.ChannelNoUpdate, " ")
for _, noUpdateChannel := range noUpdateChannels {
if noUpdateChannel == channel.Name {
return nil, "You are not allowed to post message updates in this channel"
}
}
}
if channel.Name != p.Channel {
return post, ""
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment