summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/platform/model/channel_search.go
blob: 2c041503d87ea302a5ab0d715c12286448a37639 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package model

import (
	"encoding/json"
	"io"
)

type ChannelSearch struct {
	Term string `json:"term"`
}

// ToJson convert a Channel to a json string
func (c *ChannelSearch) ToJson() string {
	b, err := json.Marshal(c)
	if err != nil {
		return ""
	} else {
		return string(b)
	}
}

// ChannelSearchFromJson will decode the input and return a Channel
func ChannelSearchFromJson(data io.Reader) *ChannelSearch {
	decoder := json.NewDecoder(data)
	var cs ChannelSearch
	err := decoder.Decode(&cs)
	if err == nil {
		return &cs
	} else {
		return nil
	}
}