github.com/spline-fu/mattermost-server@v4.10.10+incompatible/model/command_args.go (about)

     1  // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package model
     5  
     6  import (
     7  	"encoding/json"
     8  	"io"
     9  
    10  	goi18n "github.com/nicksnyder/go-i18n/i18n"
    11  )
    12  
    13  type CommandArgs struct {
    14  	UserId    string               `json:"user_id"`
    15  	ChannelId string               `json:"channel_id"`
    16  	TeamId    string               `json:"team_id"`
    17  	RootId    string               `json:"root_id"`
    18  	ParentId  string               `json:"parent_id"`
    19  	Command   string               `json:"command"`
    20  	SiteURL   string               `json:"-"`
    21  	T         goi18n.TranslateFunc `json:"-"`
    22  	Session   Session              `json:"-"`
    23  }
    24  
    25  func (o *CommandArgs) ToJson() string {
    26  	b, _ := json.Marshal(o)
    27  	return string(b)
    28  }
    29  
    30  func CommandArgsFromJson(data io.Reader) *CommandArgs {
    31  	var o *CommandArgs
    32  	json.NewDecoder(data).Decode(&o)
    33  	return o
    34  }