mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* MM-31064: Simplify indentation Reduce indentation where possible. ```release-note NONE ``` Command ran to verify: golangci-lint run --disable-all --enable golint --max-issues-per-linter=10000 --max-same-issues=100000 ./... | grep "block ends with a return state" https://mattermost.atlassian.net/browse/MM-31064 * incorporate review comments * enable golint for outdent rule * fix remaining issues Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
)
|
|
|
|
const (
|
|
PUSH_STATUS = "status"
|
|
PUSH_STATUS_OK = "OK"
|
|
PUSH_STATUS_FAIL = "FAIL"
|
|
PUSH_STATUS_REMOVE = "REMOVE"
|
|
PUSH_STATUS_ERROR_MSG = "error"
|
|
)
|
|
|
|
type PushResponse map[string]string
|
|
|
|
func NewOkPushResponse() PushResponse {
|
|
m := make(map[string]string)
|
|
m[PUSH_STATUS] = PUSH_STATUS_OK
|
|
return m
|
|
}
|
|
|
|
func NewRemovePushResponse() PushResponse {
|
|
m := make(map[string]string)
|
|
m[PUSH_STATUS] = PUSH_STATUS_REMOVE
|
|
return m
|
|
}
|
|
|
|
func NewErrorPushResponse(message string) PushResponse {
|
|
m := make(map[string]string)
|
|
m[PUSH_STATUS] = PUSH_STATUS_FAIL
|
|
m[PUSH_STATUS_ERROR_MSG] = message
|
|
return m
|
|
}
|
|
|
|
func (pr *PushResponse) ToJson() string {
|
|
b, _ := json.Marshal(pr)
|
|
return string(b)
|
|
}
|
|
|
|
func PushResponseFromJson(data io.Reader) PushResponse {
|
|
decoder := json.NewDecoder(data)
|
|
|
|
var objmap PushResponse
|
|
if err := decoder.Decode(&objmap); err != nil {
|
|
return make(map[string]string)
|
|
}
|
|
return objmap
|
|
}
|