[GH-6798] added a new api endpoint to get the bulk reactions for posts (#10049)
* 6798 added a new api to get the bulk reactions for posts * 6798 added the permsission check before getting the reactions * GH-6798 added a new app function for the new endpoint * 6798 added a store method to get reactions for multiple posts * 6798 connected the app function with the new store function * 6798 fixed the review comments
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
7b7b89d5ae
Коммит
99160ff0bc
@@ -3592,6 +3592,16 @@ func (c *Client4) DeleteReaction(reaction *Reaction) (bool, *Response) {
|
||||
return CheckStatusOK(r), BuildResponse(r)
|
||||
}
|
||||
|
||||
// FetchBulkReactions returns a map of postIds and corresponding reactions
|
||||
func (c *Client4) GetBulkReactions(postIds []string) (map[string][]*Reaction, *Response) {
|
||||
r, err := c.DoApiPost(c.GetPostsRoute()+"/ids/reactions", ArrayToJson(postIds))
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return MapPostIdToReactionsFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
|
||||
// Timezone Section
|
||||
|
||||
// GetSupportedTimezone returns a page of supported timezones on the system.
|
||||
|
||||
@@ -37,6 +37,22 @@ func ReactionsToJson(o []*Reaction) string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func MapPostIdToReactionsToJson(o map[string][]*Reaction) string {
|
||||
b, _ := json.Marshal(o)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func MapPostIdToReactionsFromJson(data io.Reader) map[string][]*Reaction {
|
||||
decoder := json.NewDecoder(data)
|
||||
|
||||
var objmap map[string][]*Reaction
|
||||
if err := decoder.Decode(&objmap); err != nil {
|
||||
return make(map[string][]*Reaction)
|
||||
} else {
|
||||
return objmap
|
||||
}
|
||||
}
|
||||
|
||||
func ReactionsFromJson(data io.Reader) []*Reaction {
|
||||
var o []*Reaction
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user