1
0
mirror of synced 2024-11-21 20:46:05 +03:00

Merge pull request #18 from gwinn/master

add constants with feature values
This commit is contained in:
Alex Lushpai 2018-08-17 15:20:21 +03:00 committed by GitHub
commit 993f0114b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 53 deletions

View File

@ -32,14 +32,14 @@ func main() {
"message_read",
},
Settings: ChannelSettings{
ReceiveMessageMode: "always",
ReceiveMessageMode: MsgModeAlways,
SpamAllowed: false,
Features: ChannelFeatures{
StatusDelivered: "none",
MessageDeleting: "send",
MessageEditing: "both",
MessageQuoting: "both",
ImageMessage: "receive",
StatusDelivered: ChannelFeatureNone,
MessageDeleting: ChannelFeatureSend,
MessageEditing: ChannelFeatureBoth,
MessageQuoting: ChannelFeatureBoth,
ImageMessage: ChannelFeatureReceive,
},
},
}

View File

@ -31,14 +31,14 @@ func New(url string, token string) *MgClient {
// "message_read",
// },
// Settings: ChannelSettings{
// ReceiveMessageMode: "always",
// ReceiveMessageMode: MsgModeAlways,
// SpamAllowed: false,
// Features: ChannelFeatures{
// StatusDelivered: "none",
// MessageDeleting: "send",
// MessageEditing: "both",
// MessageQuoting: "both",
// ImageMessage: "receive",
// StatusDelivered: ChannelFeatureNone,
// MessageDeleting: ChannelFeatureSend,
// MessageEditing: ChannelFeatureBoth,
// MessageQuoting: ChannelFeatureBoth,
// ImageMessage: ChannelFeatureReceive,
// },
// },
// }
@ -84,14 +84,14 @@ func (c *MgClient) ActivateTransportChannel(request Channel) (ActivateResponse,
// "message_read",
// },
// Settings: ChannelSettings{
// ReceiveMessageMode: "always",
// ReceiveMessageMode: MsgModeTimeLimited,
// SpamAllowed: false,
// Features: ChannelFeatures{
// StatusDelivered: "none",
// MessageDeleting: "send",
// MessageEditing: "both",
// MessageQuoting: "both",
// ImageMessage: "receive",
// StatusDelivered: ChannelFeatureNone,
// MessageDeleting: ChannelFeatureSend,
// MessageEditing: ChannelFeatureBoth,
// MessageQuoting: ChannelFeatureBoth,
// ImageMessage: ChannelFeatureReceive,
// },
// },
// }
@ -277,7 +277,7 @@ func (c *MgClient) DeleteMessage(request DeleteData) (MessagesResponse, int, err
outgoing, _ := json.Marshal(&request)
data, status, err := c.DeleteRequest(
"/messages/",
"/messages",
[]byte(outgoing),
)
if err != nil {

View File

@ -29,14 +29,14 @@ func TestMgClient_ActivateTransportChannel(t *testing.T) {
"message_read",
},
Settings: ChannelSettings{
ReceiveMessageMode: "always",
ReceiveMessageMode: MsgModeAlways,
SpamAllowed: false,
Features: ChannelFeatures{
StatusDelivered: "none",
MessageDeleting: "send",
MessageEditing: "both",
MessageQuoting: "both",
ImageMessage: "receive",
StatusDelivered: ChannelFeatureNone,
MessageDeleting: ChannelFeatureSend,
MessageEditing: ChannelFeatureBoth,
MessageQuoting: ChannelFeatureBoth,
ImageMessage: ChannelFeatureReceive,
},
},
}
@ -61,14 +61,14 @@ func TestMgClient_ActivateNewTransportChannel(t *testing.T) {
"message_read",
},
Settings: ChannelSettings{
ReceiveMessageMode: "always",
ReceiveMessageMode: MsgModeTimeLimited,
SpamAllowed: false,
Features: ChannelFeatures{
StatusDelivered: "none",
MessageDeleting: "send",
MessageEditing: "both",
MessageQuoting: "both",
ImageMessage: "receive",
StatusDelivered: ChannelFeatureNone,
MessageDeleting: ChannelFeatureSend,
MessageEditing: ChannelFeatureBoth,
MessageQuoting: ChannelFeatureBoth,
ImageMessage: ChannelFeatureReceive,
},
},
}
@ -108,11 +108,11 @@ func TestMgClient_UpdateTransportChannel(t *testing.T) {
ReceiveMessageMode: "always",
SpamAllowed: false,
Features: ChannelFeatures{
StatusDelivered: "none",
MessageDeleting: "send",
MessageEditing: "both",
MessageQuoting: "both",
ImageMessage: "receive",
StatusDelivered: ChannelFeatureNone,
MessageDeleting: ChannelFeatureSend,
MessageEditing: ChannelFeatureBoth,
MessageQuoting: ChannelFeatureBoth,
ImageMessage: ChannelFeatureReceive,
},
},
}

View File

@ -5,6 +5,17 @@ import (
"time"
)
const (
ChannelFeatureNone string = "none"
ChannelFeatureReceive string = "receive"
ChannelFeatureSend string = "send"
ChannelFeatureBoth string = "both"
MsgModeNever string = "never"
MsgModeTimeLimited string = "time-limited"
MsgModeAlways string = "always"
)
// MgClient type
type MgClient struct {
URL string `json:"url"`
@ -59,22 +70,22 @@ type DeleteResponse struct {
// User struct
type User struct {
ExternalID string `json:"external_id" json:"external_id"`
Nickname string `json:"nickname" json:"nickname"`
Firstname string `json:"first_name,omitempty" json:"first_name"`
Lastname string `json:"last_name,omitempty" json:"last_name"`
Avatar string `json:"avatar,omitempty" json:"avatar"`
ProfileURL string `json:"profile_url,omitempty" json:"profile_url"`
Country string `json:"country,omitempty" json:"country"`
Language string `json:"language,omitempty" json:"language"`
Phone string `json:"phone,omitempty" json:"phone"`
ExternalID string `json:"external_id"`
Nickname string `json:"nickname"`
Firstname string `json:"first_name,omitempty"`
Lastname string `json:"last_name,omitempty"`
Avatar string `json:"avatar,omitempty"`
ProfileURL string `json:"profile_url,omitempty"`
Country string `json:"country,omitempty"`
Language string `json:"language,omitempty"`
Phone string `json:"phone,omitempty"`
}
// Message struct
type Message struct {
ExternalID string `json:"external_id" json:"external_id"`
Type string `json:"type,omitempty" json:"type"`
Text string `json:"text,omitempty" json:"text"`
ExternalID string `json:"external_id"`
Type string `json:"type,omitempty"`
Text string `json:"text,omitempty"`
}
// SendMessage struct
@ -91,11 +102,11 @@ type UpdateMessage struct {
// SendData struct
type SendData struct {
Message SendMessage `json:"message" json:"message"`
User User `json:"user" json:"user"`
Channel uint64 `json:"channel" json:"channel"`
ExternalChatID string `json:"external_chat_id" json:"external_chat_id"`
Quote *SendMessageRequestQuote `json:"quote,omitempty" json:"quote,omitempty"`
Message SendMessage `json:"message"`
User User `json:"user"`
Channel uint64 `json:"channel"`
ExternalChatID string `json:"external_chat_id"`
Quote *SendMessageRequestQuote `json:"quote,omitempty"`
}
type SendMessageRequestQuote struct {