mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* initial work on rewriting test cases using the raw literal format * split out the embedded tests into separate file and implement the test using a generic tester function * initial work on rewriting test cases using the raw literal format * split out the embedded tests into separate file and implement the test using a generic tester function * moved tests to separate dir to avoid conflicts * removed duplicate files * added license header * fixed plugin paths * moved all trivial tests to separate files created "meta-test" that scans a folder of api tests and runs them * remove rpc tests from make * use fileutil.FindDir instead of pwd clean up the test files
69 lines
1.3 KiB
Go
69 lines
1.3 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/mattermost/mattermost-server/model"
|
|
"github.com/mattermost/mattermost-server/plugin"
|
|
)
|
|
|
|
type MyPlugin struct {
|
|
plugin.MattermostPlugin
|
|
}
|
|
|
|
func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
|
|
uid := "{{.BasicUser.Id}}"
|
|
if err := p.API.UpdateUserActive(uid, true); err != nil {
|
|
return nil, err.Error()
|
|
}
|
|
|
|
user, err := p.API.GetUser(uid)
|
|
if err != nil {
|
|
return nil, err.Error()
|
|
}
|
|
|
|
if int64(0) != user.DeleteAt {
|
|
return nil, "DeleteAt value is not 0"
|
|
}
|
|
|
|
if err = p.API.UpdateUserActive(uid, false); err != nil {
|
|
return nil, err.Error()
|
|
}
|
|
|
|
user, err = p.API.GetUser(uid)
|
|
if err != nil {
|
|
return nil, err.Error()
|
|
}
|
|
if user == nil {
|
|
return nil, "GetUser returned nil"
|
|
}
|
|
|
|
if int64(0) == user.DeleteAt {
|
|
return nil, "DeleteAt value is 0"
|
|
}
|
|
|
|
if err = p.API.UpdateUserActive(uid, true); err != nil {
|
|
return nil, err.Error()
|
|
}
|
|
|
|
if err = p.API.UpdateUserActive(uid, true); err != nil {
|
|
return nil, err.Error()
|
|
}
|
|
|
|
user, err = p.API.GetUser(uid)
|
|
if err != nil {
|
|
return nil, err.Error()
|
|
}
|
|
|
|
if int64(0) != user.DeleteAt {
|
|
return nil, "DeleteAt value is not 0"
|
|
}
|
|
|
|
return nil, ""
|
|
}
|
|
|
|
func main() {
|
|
plugin.ClientMain(&MyPlugin{})
|
|
}
|