[MM-17069] Api endpoint to unread a channel (#11794)

* [MM-17069] endpoint to unread a channel from post

* [MM-17069] update mock

* [MM-17069] first passing test

* [MM-17069] fix SQL typo

* [MM-17069] fix msgCount

* add tests

* [MM-17069] Fix tests

* [MM-16069] Remove trash, add comments

* [MM-16069] Add message to errors

* [MM-17069] fix go fmt

* [MM-17069] return an UnreadChannel response

* [MM-17069] added unauthorized test

* [MM-17069] fix operator

* [MM-17069] refactor tests

* [MM-16069] back to green tests

* [MM-17069] change url to include user

* [MM-17069] Fixing code review comments

* [MM-17069] One shouldn't fix manually what a machine can fix better

* [MM-17069] change response type, update tests

* [MM-17069] fix permission error

* [MM-17069] Add tests for edit_other_users permission

* [MM-17069] no magic numbers
Этот коммит содержится в:
Guillermo Vayá
2019-08-21 14:48:25 +02:00
коммит произвёл Harrison Healey
родитель bd152c6534
Коммит 6b0f4f1aee
10 изменённых файлов: 365 добавлений и 0 удалений

Просмотреть файл

@@ -31,6 +31,16 @@ type ChannelUnread struct {
NotifyProps StringMap `json:"-"`
}
type ChannelUnreadAt struct {
TeamId string `json:"team_id"`
UserId string `json:"user_id"`
ChannelId string `json:"channel_id"`
MsgCount int64 `json:"msg_count"`
MentionCount int64 `json:"mention_count"`
LastViewedAt int64 `json:"last_viewed_at"`
NotifyProps StringMap `json:"-"`
}
type ChannelMember struct {
ChannelId string `json:"channel_id"`
UserId string `json:"user_id"`
@@ -67,6 +77,11 @@ func (o *ChannelUnread) ToJson() string {
return string(b)
}
func (o *ChannelUnreadAt) ToJson() string {
b, _ := json.Marshal(o)
return string(b)
}
func ChannelMembersFromJson(data io.Reader) *ChannelMembers {
var o *ChannelMembers
json.NewDecoder(data).Decode(&o)
@@ -79,6 +94,12 @@ func ChannelUnreadFromJson(data io.Reader) *ChannelUnread {
return o
}
func ChannelUnreadAtFromJson(data io.Reader) *ChannelUnreadAt {
var o *ChannelUnreadAt
json.NewDecoder(data).Decode(&o)
return o
}
func (o *ChannelMember) ToJson() string {
b, _ := json.Marshal(o)
return string(b)

Просмотреть файл

@@ -2480,6 +2480,16 @@ func (c *Client4) PatchPost(postId string, patch *PostPatch) (*Post, *Response)
return PostFromJson(r.Body), BuildResponse(r)
}
// SetPostUnread marks channel where post belongs as unread on the time of the provided post.
func (c *Client4) SetPostUnread(userId string, postId string) *Response {
r, err := c.DoApiPost(c.GetUserRoute(userId)+c.GetPostRoute(postId)+"/set_unread", "")
if err != nil {
return BuildErrorResponse(r, err)
}
defer closeBody(r)
return BuildResponse(r)
}
// PinPost pin a post based on provided post id string.
func (c *Client4) PinPost(postId string) (bool, *Response) {
r, err := c.DoApiPost(c.GetPostRoute(postId)+"/pin", "")