4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-09-11 01:52:30 +00:00

Update vendor (#1265)

This commit is contained in:
Wim
2020-10-19 23:40:00 +02:00
committed by GitHub
parent 950f2759bd
commit 075a84427f
242 changed files with 22338 additions and 1486 deletions

View File

@@ -56,6 +56,65 @@ type InteractionCallback struct {
DialogSubmissionCallback
ViewSubmissionCallback
ViewClosedCallback
// FIXME(kanata2): just workaround for backward-compatibility.
// See also https://github.com/slack-go/slack/issues/816
RawState json.RawMessage `json:"state,omitempty"`
// BlockActionState stands for the `state` field in block_actions type.
// NOTE: InteractionCallback.State has a role for the state of dialog_submission type,
// so we cannot use this field for backward-compatibility for now.
BlockActionState *BlockActionStates `json:"-"`
}
type BlockActionStates struct {
Values map[string]map[string]BlockAction `json:"values"`
}
func (ic *InteractionCallback) MarshalJSON() ([]byte, error) {
type alias InteractionCallback
tmp := alias(*ic)
if tmp.Type == InteractionTypeBlockActions {
if tmp.BlockActionState == nil {
tmp.RawState = []byte(`{}`)
} else {
state, err := json.Marshal(tmp.BlockActionState.Values)
if err != nil {
return nil, err
}
tmp.RawState = []byte(`{"values":` + string(state) + `}`)
}
} else if ic.Type == InteractionTypeDialogSubmission {
tmp.RawState = []byte(tmp.State)
}
// Use pointer for go1.7
return json.Marshal(&tmp)
}
func (ic *InteractionCallback) UnmarshalJSON(b []byte) error {
type alias InteractionCallback
tmp := struct {
Type InteractionType `json:"type"`
*alias
}{
alias: (*alias)(ic),
}
if err := json.Unmarshal(b, &tmp); err != nil {
return err
}
*ic = InteractionCallback(*tmp.alias)
ic.Type = tmp.Type
if ic.Type == InteractionTypeBlockActions {
if len(ic.RawState) > 0 {
err := json.Unmarshal(ic.RawState, &ic.BlockActionState)
if err != nil {
return err
}
}
} else if ic.Type == InteractionTypeDialogSubmission {
ic.State = string(ic.RawState)
}
return nil
}
type Container struct {