summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-06-11 23:07:42 +0200
committerGitHub <noreply@github.com>2022-06-11 23:07:42 +0200
commit8751fb4bb1eb7cd34ed63be9b3801b8aeac71a1d (patch)
tree601d2616b05b5b197bd2a3ae7cb245b1a0ea17e7 /vendor/github.com/mattermost/mattermost-server/v6/model/client4.go
parent3819062574ac7e4af6a562bf40a425469a7752fb (diff)
downloadmatterbridge-msglm-8751fb4bb1eb7cd34ed63be9b3801b8aeac71a1d.tar.gz
matterbridge-msglm-8751fb4bb1eb7cd34ed63be9b3801b8aeac71a1d.tar.bz2
matterbridge-msglm-8751fb4bb1eb7cd34ed63be9b3801b8aeac71a1d.zip
Update dependencies (#1841)
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v6/model/client4.go')
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v6/model/client4.go150
1 files changed, 118 insertions, 32 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go b/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go
index 000c0b41..c6e7d887 100644
--- a/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go
+++ b/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go
@@ -2638,6 +2638,30 @@ func (c *Client4) InviteGuestsToTeam(teamId string, userEmails []string, channel
// InviteUsersToTeam invite users by email to the team.
func (c *Client4) InviteUsersToTeamGracefully(teamId string, userEmails []string) ([]*EmailInviteWithError, *Response, error) {
r, err := c.DoAPIPost(c.teamRoute(teamId)+"/invite/email?graceful="+c.boolString(true), ArrayToJSON(userEmails))
+
+ if err != nil {
+ return nil, BuildResponse(r), err
+ }
+ defer closeBody(r)
+ var list []*EmailInviteWithError
+ if jsonErr := json.NewDecoder(r.Body).Decode(&list); jsonErr != nil {
+ return nil, nil, NewAppError("InviteUsersToTeamGracefully", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
+ }
+ return list, BuildResponse(r), nil
+}
+
+// InviteUsersToTeam invite users by email to the team.
+func (c *Client4) InviteUsersToTeamAndChannelsGracefully(teamId string, userEmails []string, channelIds []string, message string) ([]*EmailInviteWithError, *Response, error) {
+ memberInvite := MemberInvite{
+ Emails: userEmails,
+ ChannelIds: channelIds,
+ Message: message,
+ }
+ buf, err := json.Marshal(memberInvite)
+ if err != nil {
+ return nil, nil, NewAppError("InviteMembersToTeamAndChannels", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError)
+ }
+ r, err := c.DoAPIPostBytes(c.teamRoute(teamId)+"/invite/email?graceful="+c.boolString(true), buf)
if err != nil {
return nil, BuildResponse(r), err
}
@@ -3748,6 +3772,49 @@ func (c *Client4) GetPostThread(postId string, etag string, collapsedThreads boo
return &list, BuildResponse(r), nil
}
+// GetPostThreadWithOpts gets a post with all the other posts in the same thread.
+func (c *Client4) GetPostThreadWithOpts(postID string, etag string, opts GetPostsOptions) (*PostList, *Response, error) {
+ urlVal := c.postRoute(postID) + "/thread"
+
+ values := url.Values{}
+ if opts.CollapsedThreads {
+ values.Set("collapsedThreads", "true")
+ }
+ if opts.CollapsedThreadsExtended {
+ values.Set("collapsedThreadsExtended", "true")
+ }
+ if opts.SkipFetchThreads {
+ values.Set("skipFetchThreads", "true")
+ }
+ if opts.PerPage != 0 {
+ values.Set("perPage", strconv.Itoa(opts.PerPage))
+ }
+ if opts.FromPost != "" {
+ values.Set("fromPost", opts.FromPost)
+ }
+ if opts.FromCreateAt != 0 {
+ values.Set("fromCreateAt", strconv.FormatInt(opts.FromCreateAt, 10))
+ }
+ if opts.Direction != "" {
+ values.Set("direction", opts.Direction)
+ }
+ urlVal += "?" + values.Encode()
+
+ r, err := c.DoAPIGet(urlVal, etag)
+ if err != nil {
+ return nil, BuildResponse(r), err
+ }
+ defer closeBody(r)
+ var list PostList
+ if r.StatusCode == http.StatusNotModified {
+ return &list, BuildResponse(r), nil
+ }
+ if jsonErr := json.NewDecoder(r.Body).Decode(&list); jsonErr != nil {
+ return nil, nil, NewAppError("GetPostThread", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
+ }
+ return &list, BuildResponse(r), nil
+}
+
// GetPostsForChannel gets a page of posts with an array for ordering for a channel.
func (c *Client4) GetPostsForChannel(channelId string, page, perPage int, etag string, collapsedThreads bool) (*PostList, *Response, error) {
query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
@@ -6429,6 +6496,39 @@ func (c *Client4) GetBulkReactions(postIds []string) (map[string][]*Reaction, *R
return reactions, BuildResponse(r), nil
}
+func (c *Client4) GetTopReactionsForTeamSince(teamId string, timeRange string, page int, perPage int) (*TopReactionList, *Response, error) {
+ query := fmt.Sprintf("?time_range=%v&page=%v&per_page=%v", timeRange, page, perPage)
+ r, err := c.DoAPIGet(c.teamRoute(teamId)+"/top/reactions"+query, "")
+ if err != nil {
+ return nil, BuildResponse(r), err
+ }
+ defer closeBody(r)
+ var topReactions *TopReactionList
+ if jsonErr := json.NewDecoder(r.Body).Decode(&topReactions); jsonErr != nil {
+ return nil, nil, NewAppError("GetTopReactionsForTeamSince", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
+ }
+ return topReactions, BuildResponse(r), nil
+}
+
+func (c *Client4) GetTopReactionsForUserSince(teamId string, timeRange string, page int, perPage int) (*TopReactionList, *Response, error) {
+ query := fmt.Sprintf("?time_range=%v&page=%v&per_page=%v", timeRange, page, perPage)
+
+ if teamId != "" {
+ query += fmt.Sprintf("&team_id=%v", teamId)
+ }
+
+ r, err := c.DoAPIGet(c.usersRoute()+"/me/top/reactions"+query, "")
+ if err != nil {
+ return nil, BuildResponse(r), err
+ }
+ defer closeBody(r)
+ var topReactions *TopReactionList
+ if jsonErr := json.NewDecoder(r.Body).Decode(&topReactions); jsonErr != nil {
+ return nil, nil, NewAppError("GetTopReactionsForUserSince", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
+ }
+ return topReactions, BuildResponse(r), nil
+}
+
// Timezone Section
// GetSupportedTimezone returns a page of supported timezones on the system.
@@ -7658,18 +7758,6 @@ func (c *Client4) GetSubscription() (*Subscription, *Response, error) {
return subscription, BuildResponse(r), nil
}
-func (c *Client4) GetSubscriptionStats() (*SubscriptionStats, *Response, error) {
- r, err := c.DoAPIGet(c.cloudRoute()+"/subscription/stats", "")
- if err != nil {
- return nil, BuildResponse(r), err
- }
- defer closeBody(r)
-
- var stats *SubscriptionStats
- json.NewDecoder(r.Body).Decode(&stats)
- return stats, BuildResponse(r), nil
-}
-
func (c *Client4) GetInvoicesForSubscription() ([]*Invoice, *Response, error) {
r, err := c.DoAPIGet(c.cloudRoute()+"/subscription/invoices", "")
if err != nil {
@@ -7782,6 +7870,12 @@ func (c *Client4) GetUserThreads(userId, teamId string, options GetUserThreadsOp
if options.Unread {
v.Set("unread", "true")
}
+ if options.ThreadsOnly {
+ v.Set("threadsOnly", "true")
+ }
+ if options.TotalsOnly {
+ v.Set("totalsOnly", "true")
+ }
url := c.userThreadsRoute(userId, teamId)
if len(v) > 0 {
url += "?" + v.Encode()
@@ -7826,6 +7920,18 @@ func (c *Client4) UpdateThreadsReadForUser(userId, teamId string) (*Response, er
return BuildResponse(r), nil
}
+func (c *Client4) SetThreadUnreadByPostId(userId, teamId, threadId, postId string) (*ThreadResponse, *Response, error) {
+ r, err := c.DoAPIPost(fmt.Sprintf("%s/set_unread/%s", c.userThreadRoute(userId, teamId, threadId), postId), "")
+ if err != nil {
+ return nil, BuildResponse(r), err
+ }
+ defer closeBody(r)
+ var thread ThreadResponse
+ json.NewDecoder(r.Body).Decode(&thread)
+
+ return &thread, BuildResponse(r), nil
+}
+
func (c *Client4) UpdateThreadReadForUser(userId, teamId, threadId string, timestamp int64) (*ThreadResponse, *Response, error) {
r, err := c.DoAPIPut(fmt.Sprintf("%s/read/%d", c.userThreadRoute(userId, teamId, threadId), timestamp), "")
if err != nil {
@@ -7854,26 +7960,6 @@ func (c *Client4) UpdateThreadFollowForUser(userId, teamId, threadId string, sta
return BuildResponse(r), nil
}
-func (c *Client4) SendAdminUpgradeRequestEmail() (*Response, error) {
- r, err := c.DoAPIPost(c.cloudRoute()+"/subscription/limitreached/invite", "")
- if err != nil {
- return BuildResponse(r), err
- }
- defer closeBody(r)
-
- return BuildResponse(r), nil
-}
-
-func (c *Client4) SendAdminUpgradeRequestEmailOnJoin() (*Response, error) {
- r, err := c.DoAPIPost(c.cloudRoute()+"/subscription/limitreached/join", "")
- if err != nil {
- return BuildResponse(r), err
- }
- defer closeBody(r)
-
- return BuildResponse(r), nil
-}
-
func (c *Client4) GetAllSharedChannels(teamID string, page, perPage int) ([]*SharedChannel, *Response, error) {
url := fmt.Sprintf("%s/%s?page=%d&per_page=%d", c.sharedChannelsRoute(), teamID, page, perPage)
r, err := c.DoAPIGet(url, "")