PLT-5012 Combine updateLastViewedAt, setLastViewedAt and setActiveChannel into a single API (#4840)
* Combine updateLastViewedAt, setLastViewedAt and setActiveChannel into a single API * Remove preference DB writes
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
139cb52c99
Коммит
ba6e370ca7
@@ -48,6 +48,13 @@ type Result struct {
|
||||
Data interface{}
|
||||
}
|
||||
|
||||
type ResponseMetadata struct {
|
||||
StatusCode int
|
||||
Error *AppError
|
||||
RequestId string
|
||||
Etag string
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
Url string // The location of the server like "http://localhost:8065"
|
||||
ApiUrl string // The api location of the server like "http://localhost:8065/api/v3"
|
||||
@@ -1329,6 +1336,7 @@ func (c *Client) RemoveChannelMember(id, user_id string) (*Result, *AppError) {
|
||||
// UpdateLastViewedAt will mark a channel as read.
|
||||
// The channelId indicates the channel to mark as read. If active is true, push notifications
|
||||
// will be cleared if there are unread messages. The default for active is true.
|
||||
// SCHEDULED FOR DEPRECATION IN 3.8 - use ViewChannel instead
|
||||
func (c *Client) UpdateLastViewedAt(channelId string, active bool) (*Result, *AppError) {
|
||||
data := make(map[string]interface{})
|
||||
data["active"] = active
|
||||
@@ -1341,6 +1349,24 @@ func (c *Client) UpdateLastViewedAt(channelId string, active bool) (*Result, *Ap
|
||||
}
|
||||
}
|
||||
|
||||
// ViewChannel performs all the actions related to viewing a channel. This includes marking
|
||||
// the channel and the previous one as read, marking the channel as being actively viewed.
|
||||
// ChannelId is required but may be blank to indicate no channel is being viewed.
|
||||
// PrevChannelId is optional, populate to indicate a channel switch occurred. Optionally
|
||||
// provide a non-zero Time, in Unix milliseconds, to manually set the viewing time.
|
||||
func (c *Client) ViewChannel(params ChannelView) (bool, *ResponseMetadata) {
|
||||
if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/view", params.ToJson()); err != nil {
|
||||
return false, &ResponseMetadata{StatusCode: r.StatusCode, Error: err}
|
||||
} else {
|
||||
return c.CheckStatusOK(r),
|
||||
&ResponseMetadata{
|
||||
StatusCode: r.StatusCode,
|
||||
RequestId: r.Header.Get(HEADER_REQUEST_ID),
|
||||
Etag: r.Header.Get(HEADER_ETAG_SERVER),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) GetChannelStats(id string, etag string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiGet(c.GetChannelRoute(id)+"/stats", "", etag); err != nil {
|
||||
return nil, err
|
||||
@@ -1718,6 +1744,7 @@ func (c *Client) GetStatusesByIds(userIds []string) (*Result, *AppError) {
|
||||
// SetActiveChannel sets the the channel id the user is currently viewing.
|
||||
// The channelId key is required but the value can be blank. Returns standard
|
||||
// response.
|
||||
// SCHEDULED FOR DEPRECATION IN 3.8 - use ViewChannel instead
|
||||
func (c *Client) SetActiveChannel(channelId string) (*Result, *AppError) {
|
||||
data := map[string]string{}
|
||||
data["channel_id"] = channelId
|
||||
|
||||
Ссылка в новой задаче
Block a user