protonmail: properly set action when creating draft

This commit is contained in:
emersion 2018-07-11 11:57:41 +01:00
parent b8a6d64e5c
commit 853a879e51
1 changed files with 18 additions and 3 deletions

View File

@ -40,6 +40,14 @@ const (
_ _
) )
type MessageAction int
const (
MessageReply MessageAction = iota
MessageReplyAll
MessageForward
)
type MessageAddress struct { type MessageAddress struct {
Address string Address string
Name string Name string
@ -251,11 +259,18 @@ func (c *Client) GetMessage(id string) (*Message, error) {
// CreateDraftMessage creates a new draft message. ToList, CCList, BCCList, // CreateDraftMessage creates a new draft message. ToList, CCList, BCCList,
// Subject, Body and AddressID are required in msg. // Subject, Body and AddressID are required in msg.
func (c *Client) CreateDraftMessage(msg *Message, parentID string) (*Message, error) { func (c *Client) CreateDraftMessage(msg *Message, parentID string) (*Message, error) {
var actionPtr *MessageAction
if parentID != "" {
// TODO: support other actions
action := MessageReply
actionPtr = &action
}
reqData := struct { reqData := struct {
Message *Message Message *Message
ParentID string `json:",omitempty"` ParentID string `json:",omitempty"`
Action *int `json:",omitempty"` Action *MessageAction `json:",omitempty"`
}{msg, parentID, nil} }{msg, parentID, actionPtr}
req, err := c.newJSONRequest(http.MethodPost, "/messages", &reqData) req, err := c.newJSONRequest(http.MethodPost, "/messages", &reqData)
if err != nil { if err != nil {
return nil, err return nil, err