1
0
mirror of synced 2024-11-25 06:26:03 +03:00

update features, remove events

This commit is contained in:
Alex Lushpai 2018-08-21 13:37:49 +03:00
parent 7185cc94c0
commit 9d750e73f6
4 changed files with 72 additions and 89 deletions

View File

@ -27,19 +27,17 @@ func main() {
var client = v1.New("https://token.url", "cb8ccf05e38a47543ad8477d49bcba99be73bff503ea6") var client = v1.New("https://token.url", "cb8ccf05e38a47543ad8477d49bcba99be73bff503ea6")
ch := Channel{ ch := Channel{
Type: "telegram", Type: "telegram",
Events: []string{
"message_sent",
"message_read",
},
Settings: ChannelSettings{ Settings: ChannelSettings{
ReceiveMessageMode: MsgModeAlways,
SpamAllowed: false, SpamAllowed: false,
Features: ChannelFeatures{ Status: Status{
StatusDelivered: ChannelFeatureNone, Delivered: ChannelFeatureNone,
MessageDeleting: ChannelFeatureSend, Read: ChannelFeatureReceive,
MessageEditing: ChannelFeatureBoth, },
MessageQuoting: ChannelFeatureBoth, Text: ChannelSettingsText{
ImageMessage: ChannelFeatureReceive, Creating: ChannelFeatureBoth,
Editing: ChannelFeatureSend,
Quoting: ChannelFeatureReceive,
Deleting: ChannelFeatureBoth,
}, },
}, },
} }

View File

@ -26,19 +26,17 @@ func New(url string, token string) *MgClient {
// //
// request := ActivateRequest{ // request := ActivateRequest{
// Type: "telegram", // Type: "telegram",
// Events: []string{
// "message_sent",
// "message_read",
// },
// Settings: ChannelSettings{ // Settings: ChannelSettings{
// ReceiveMessageMode: MsgModeAlways,
// SpamAllowed: false, // SpamAllowed: false,
// Features: ChannelFeatures{ // Status: Status{
// StatusDelivered: ChannelFeatureNone, // Delivered: ChannelFeatureNone,
// MessageDeleting: ChannelFeatureSend, // Read: ChannelFeatureReceive,
// MessageEditing: ChannelFeatureBoth, // },
// MessageQuoting: ChannelFeatureBoth, // Text: ChannelSettingsText{
// ImageMessage: ChannelFeatureReceive, // Creating: ChannelFeatureBoth,
// Editing: ChannelFeatureBoth,
// Quoting: ChannelFeatureReceive,
// Deleting: ChannelFeatureSend,
// }, // },
// }, // },
// } // }
@ -79,19 +77,17 @@ func (c *MgClient) ActivateTransportChannel(request Channel) (ActivateResponse,
// request := ActivateRequest{ // request := ActivateRequest{
// ID: 3053450384, // ID: 3053450384,
// Type: "telegram", // Type: "telegram",
// Events: []string{
// "message_sent",
// "message_read",
// },
// Settings: ChannelSettings{ // Settings: ChannelSettings{
// ReceiveMessageMode: MsgModeNever,
// SpamAllowed: false, // SpamAllowed: false,
// Features: ChannelFeatures{ // Status: Status{
// StatusDelivered: ChannelFeatureNone, // Delivered: ChannelFeatureNone,
// MessageDeleting: ChannelFeatureSend, // Read: ChannelFeatureReceive,
// MessageEditing: ChannelFeatureBoth, // },
// MessageQuoting: ChannelFeatureBoth, // Text: ChannelSettingsText{
// ImageMessage: ChannelFeatureReceive, // Creating: ChannelFeatureBoth,
// Editing: ChannelFeatureSend,
// Quoting: ChannelFeatureReceive,
// Deleting: ChannelFeatureBoth,
// }, // },
// }, // },
// } // }

View File

@ -24,19 +24,17 @@ func TestMgClient_ActivateTransportChannel(t *testing.T) {
ch := Channel{ ch := Channel{
ID: channelId, ID: channelId,
Type: "telegram", Type: "telegram",
Events: []string{
"message_sent",
"message_read",
},
Settings: ChannelSettings{ Settings: ChannelSettings{
ReceiveMessageMode: MsgModeAlways, SpamAllowed: false,
SpamAllowed: false, Status: Status{
Features: ChannelFeatures{ Delivered: ChannelFeatureNone,
StatusDelivered: ChannelFeatureNone, Read: ChannelFeatureReceive,
MessageDeleting: ChannelFeatureSend, },
MessageEditing: ChannelFeatureBoth, Text: ChannelSettingsText{
MessageQuoting: ChannelFeatureBoth, Creating: ChannelFeatureBoth,
ImageMessage: ChannelFeatureReceive, Editing: ChannelFeatureSend,
Quoting: ChannelFeatureReceive,
Deleting: ChannelFeatureBoth,
}, },
}, },
} }
@ -54,21 +52,17 @@ func TestMgClient_ActivateNewTransportChannel(t *testing.T) {
c := client() c := client()
ch := Channel{ ch := Channel{
Type: "telegram", Type: "telegram",
Events: []string{
"message_sent",
"message_updated",
"message_deleted",
"message_read",
},
Settings: ChannelSettings{ Settings: ChannelSettings{
ReceiveMessageMode: MsgModeNever, SpamAllowed: false,
SpamAllowed: false, Status: Status{
Features: ChannelFeatures{ Delivered: ChannelFeatureNone,
StatusDelivered: ChannelFeatureNone, Read: ChannelFeatureBoth,
MessageDeleting: ChannelFeatureSend, },
MessageEditing: ChannelFeatureBoth, Text: ChannelSettingsText{
MessageQuoting: ChannelFeatureBoth, Creating: ChannelFeatureBoth,
ImageMessage: ChannelFeatureReceive, Editing: ChannelFeatureSend,
Quoting: ChannelFeatureBoth,
Deleting: ChannelFeatureSend,
}, },
}, },
} }
@ -98,21 +92,17 @@ func TestMgClient_UpdateTransportChannel(t *testing.T) {
c := client() c := client()
ch := Channel{ ch := Channel{
ID: channelId, ID: channelId,
Events: []string{
"message_sent",
"message_updated",
"message_deleted",
"message_read",
},
Settings: ChannelSettings{ Settings: ChannelSettings{
ReceiveMessageMode: "always", SpamAllowed: false,
SpamAllowed: false, Status: Status{
Features: ChannelFeatures{ Delivered: ChannelFeatureNone,
StatusDelivered: ChannelFeatureNone, Read: ChannelFeatureBoth,
MessageDeleting: ChannelFeatureSend, },
MessageEditing: ChannelFeatureBoth, Text: ChannelSettingsText{
MessageQuoting: ChannelFeatureBoth, Creating: ChannelFeatureBoth,
ImageMessage: ChannelFeatureReceive, Editing: ChannelFeatureBoth,
Quoting: ChannelFeatureBoth,
Deleting: ChannelFeatureBoth,
}, },
}, },
} }

View File

@ -10,9 +10,6 @@ const (
ChannelFeatureReceive string = "receive" ChannelFeatureReceive string = "receive"
ChannelFeatureSend string = "send" ChannelFeatureSend string = "send"
ChannelFeatureBoth string = "both" ChannelFeatureBoth string = "both"
MsgModeNever string = "never"
MsgModeAlways string = "always"
) )
// MgClient type // MgClient type
@ -27,26 +24,28 @@ type MgClient struct {
type Channel struct { type Channel struct {
ID uint64 `json:"id,omitempty"` ID uint64 `json:"id,omitempty"`
Type string `json:"type,omitempty"` Type string `json:"type,omitempty"`
Events []string `json:"events,omitempty,brackets"`
Settings ChannelSettings `json:"settings,omitempty,brackets"` Settings ChannelSettings `json:"settings,omitempty,brackets"`
} }
// ChannelSettings struct // ChannelSettings struct
type ChannelSettings struct { type ChannelSettings struct {
Features ChannelFeatures `json:"features"` SpamAllowed bool `json:"spam_allowed"`
ReceiveMessageMode string `json:"receive_message_mode"` Status Status `json:"status"`
SpamAllowed bool `json:"spam_allowed"` Text ChannelSettingsText `json:"text"`
} }
// ChannelFeatures struct // Status struct
type ChannelFeatures struct { type Status struct {
StatusDelivered string `json:"status_delivered"` Delivered string `json:"delivered"`
StatusRead string `json:"status_read"` Read string `json:"read"`
MessageDeleting string `json:"message_deleting"` }
MessageEditing string `json:"message_editing"`
MessageQuoting string `json:"message_quoting"` // ChannelSettingsText struct
ImageMessage string `json:"image_message"` type ChannelSettingsText struct {
FileMessage string `json:"file_message"` Creating string `json:"creating"`
Editing string `json:"editing"`
Quoting string `json:"quoting"`
Deleting string `json:"deleting"`
} }
// ActivateResponse channel activation response // ActivateResponse channel activation response