Ephemeral duration should be optional
This commit is contained in:
12
chat.go
12
chat.go
@ -235,7 +235,7 @@ func (k *Keybase) SendEphemeralToChannel(channel chat1.ChatChannel, duration tim
|
||||
Message: SendMessageBody{
|
||||
Body: fmt.Sprintf(message, a...),
|
||||
},
|
||||
ExplodingLifetime: explodingLifetime{duration},
|
||||
ExplodingLifetime: &ExplodingLifetime{duration},
|
||||
}
|
||||
|
||||
r, err := k.SendMessage(opts)
|
||||
@ -255,7 +255,7 @@ func (k *Keybase) SendEphemeralToConvID(convID chat1.ConvIDStr, duration time.Du
|
||||
Message: SendMessageBody{
|
||||
Body: fmt.Sprintf(message, a...),
|
||||
},
|
||||
ExplodingLifetime: explodingLifetime{duration},
|
||||
ExplodingLifetime: &ExplodingLifetime{duration},
|
||||
}
|
||||
|
||||
r, err := k.SendMessage(opts)
|
||||
@ -267,7 +267,7 @@ func (k *Keybase) SendEphemeralToConvID(convID chat1.ConvIDStr, duration time.Du
|
||||
}
|
||||
|
||||
// ReplyToChannel sends a chat message to a channel
|
||||
func (k *Keybase) ReplyToChannel(channel chat1.ChatChannel, replyTo *chat1.MessageID, message string, a ...interface{}) (SendResponse, error) {
|
||||
func (k *Keybase) ReplyToChannel(channel chat1.ChatChannel, replyTo chat1.MessageID, message string, a ...interface{}) (SendResponse, error) {
|
||||
var r SendResponse
|
||||
|
||||
opts := SendMessageOptions{
|
||||
@ -275,7 +275,7 @@ func (k *Keybase) ReplyToChannel(channel chat1.ChatChannel, replyTo *chat1.Messa
|
||||
Message: SendMessageBody{
|
||||
Body: fmt.Sprintf(message, a...),
|
||||
},
|
||||
ReplyTo: replyTo,
|
||||
ReplyTo: &replyTo,
|
||||
}
|
||||
|
||||
r, err := k.SendMessage(opts)
|
||||
@ -287,7 +287,7 @@ func (k *Keybase) ReplyToChannel(channel chat1.ChatChannel, replyTo *chat1.Messa
|
||||
}
|
||||
|
||||
// ReplyToConvID sends a chat message to a conversation id
|
||||
func (k *Keybase) ReplyToConvID(convID chat1.ConvIDStr, replyTo *chat1.MessageID, message string, a ...interface{}) (SendResponse, error) {
|
||||
func (k *Keybase) ReplyToConvID(convID chat1.ConvIDStr, replyTo chat1.MessageID, message string, a ...interface{}) (SendResponse, error) {
|
||||
var r SendResponse
|
||||
|
||||
opts := SendMessageOptions{
|
||||
@ -295,7 +295,7 @@ func (k *Keybase) ReplyToConvID(convID chat1.ConvIDStr, replyTo *chat1.MessageID
|
||||
Message: SendMessageBody{
|
||||
Body: fmt.Sprintf(message, a...),
|
||||
},
|
||||
ReplyTo: replyTo,
|
||||
ReplyTo: &replyTo,
|
||||
}
|
||||
|
||||
r, err := k.SendMessage(opts)
|
||||
|
||||
24
types.go
24
types.go
@ -27,16 +27,16 @@ type Error struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type explodingLifetime struct {
|
||||
type ExplodingLifetime struct {
|
||||
time.Duration
|
||||
}
|
||||
|
||||
func (d *explodingLifetime) UnmarshalJSON(b []byte) (err error) {
|
||||
func (d *ExplodingLifetime) UnmarshalJSON(b []byte) (err error) {
|
||||
d.Duration, err = time.ParseDuration(strings.Trim(string(b), `"`))
|
||||
return
|
||||
}
|
||||
|
||||
func (d *explodingLifetime) MarshalJSON() (b []byte, err error) {
|
||||
func (d *ExplodingLifetime) MarshalJSON() (b []byte, err error) {
|
||||
return []byte(fmt.Sprintf(`"%s"`, d.String())), nil
|
||||
}
|
||||
|
||||
@ -46,15 +46,15 @@ type SendMessageBody struct {
|
||||
|
||||
// SendMessageOptions holds a set of options to be passed to SendMessage
|
||||
type SendMessageOptions struct {
|
||||
Channel chat1.ChatChannel `json:"channel,omitempty"`
|
||||
ConversationID chat1.ConvIDStr `json:"conversation_id,omitempty"`
|
||||
Message SendMessageBody `json:",omitempty"`
|
||||
Filename string `json:"filename,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
MessageID chat1.MessageID `json:"message_id,omitempty"`
|
||||
ConfirmLumenSend bool `json:"confirm_lumen_send"`
|
||||
ReplyTo *chat1.MessageID `json:"reply_to,omitempty"`
|
||||
ExplodingLifetime explodingLifetime `json:"exploding_lifetime,omitempty"`
|
||||
Channel chat1.ChatChannel `json:"channel,omitempty"`
|
||||
ConversationID chat1.ConvIDStr `json:"conversation_id,omitempty"`
|
||||
Message SendMessageBody `json:",omitempty"`
|
||||
Filename string `json:"filename,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
MessageID chat1.MessageID `json:"message_id,omitempty"`
|
||||
ConfirmLumenSend bool `json:"confirm_lumen_send"`
|
||||
ReplyTo *chat1.MessageID `json:"reply_to,omitempty"`
|
||||
ExplodingLifetime *ExplodingLifetime `json:"exploding_lifetime,omitempty"`
|
||||
}
|
||||
|
||||
type sendMessageParams struct {
|
||||
|
||||
Reference in New Issue
Block a user