Skip to content

Commit

Permalink
added "set expiration time"
Browse files Browse the repository at this point in the history
  • Loading branch information
pushrbx authored Sep 24, 2023
1 parent 4478686 commit 0850da5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,24 @@ func (c *Client) GetGroupedMessageCount(ctx context.Context) ([]MessageGroupCoun
return res.Counts, nil
}

func (c *Client) RemoveExpirationTime(ctx context.Context, messageID string) error {
func (c *Client) SetExpirationTimeOnMessage(ctx context.Context, messageID string, expirationTime *int64) error {
return c.SetExpirationTimeOnMessages(ctx, []string{messageID}, expirationTime)
}

func (c *Client) SetExpirationTimeOnMessages(ctx context.Context, messageIDs []string, expirationTime *int64) error {
if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) {
return r.SetBody(MessageExpireActionReq{ExpirationTime: nil, IDs: []string{messageID}}).Put("/mail/v4/messages/expire")
return r.SetBody(MessageExpireActionReq{ExpirationTime: expirationTime, IDs: messageIDs}).Put("/mail/v4/messages/expire")
}); err != nil {
return err
}

return nil
}

func (c *Client) RemoveExpirationTime(ctx context.Context, messageID string) error {
return c.SetExpirationTimeOnMessage(ctx, messageID, nil)
}

func (c *Client) RemoveExpirationTimeFromMessages(ctx context.Context, messageIDs []string) error {
return c.SetExpirationTimeOnMessages(ctx, messageIDs, nil)
}

0 comments on commit 0850da5

Please sign in to comment.