Merge pull request #20 from gwinn/master
update features, remove events
This commit is contained in:
commit
db54931d25
20
README.md
20
README.md
@ -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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
40
v1/client.go
40
v1/client.go
@ -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,
|
||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
// }
|
// }
|
||||||
|
@ -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,
|
||||||
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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -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,
|
||||||
Features: ChannelFeatures{
|
Status: Status{
|
||||||
StatusDelivered: ChannelFeatureNone,
|
Delivered: ChannelFeatureNone,
|
||||||
MessageDeleting: ChannelFeatureSend,
|
Read: ChannelFeatureBoth,
|
||||||
MessageEditing: ChannelFeatureBoth,
|
},
|
||||||
MessageQuoting: ChannelFeatureBoth,
|
Text: ChannelSettingsText{
|
||||||
ImageMessage: ChannelFeatureReceive,
|
Creating: ChannelFeatureBoth,
|
||||||
|
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,
|
||||||
Features: ChannelFeatures{
|
Status: Status{
|
||||||
StatusDelivered: ChannelFeatureNone,
|
Delivered: ChannelFeatureNone,
|
||||||
MessageDeleting: ChannelFeatureSend,
|
Read: ChannelFeatureBoth,
|
||||||
MessageEditing: ChannelFeatureBoth,
|
},
|
||||||
MessageQuoting: ChannelFeatureBoth,
|
Text: ChannelSettingsText{
|
||||||
ImageMessage: ChannelFeatureReceive,
|
Creating: ChannelFeatureBoth,
|
||||||
|
Editing: ChannelFeatureBoth,
|
||||||
|
Quoting: ChannelFeatureBoth,
|
||||||
|
Deleting: ChannelFeatureBoth,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
29
v1/types.go
29
v1/types.go
@ -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"`
|
|
||||||
ReceiveMessageMode string `json:"receive_message_mode"`
|
|
||||||
SpamAllowed bool `json:"spam_allowed"`
|
SpamAllowed bool `json:"spam_allowed"`
|
||||||
|
Status Status `json:"status"`
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user