[GH-26715] Added Pagination Support for IncomingWebHooks (#27502)

* Added Pagination Support for IncomingWebHooks

* Incorporated feedback from reviews

* Removed trailing spaces

* Restored deleted server en.json entries, fixed order in webapp en.json

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
alexcekay
2024-08-09 22:44:22 +02:00
коммит произвёл GitHub
родитель 1cf6cf4f5c
Коммит 7232b5f002
35 изменённых файлов: 515 добавлений и 97 удалений

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

@@ -4983,6 +4983,24 @@ func (c *Client4) GetIncomingWebhooks(ctx context.Context, page int, perPage int
return iwl, BuildResponse(r), nil
}
// GetIncomingWebhooksWithCount returns a page of incoming webhooks on the system including the total count. Page counting starts at 0.
func (c *Client4) GetIncomingWebhooksWithCount(ctx context.Context, page int, perPage int, etag string) (*IncomingWebhooksWithCount, *Response, error) {
query := fmt.Sprintf("?page=%v&per_page=%v&include_total_count="+c.boolString(true), page, perPage)
r, err := c.DoAPIGet(ctx, c.incomingWebhooksRoute()+query, etag)
if err != nil {
return nil, BuildResponse(r), err
}
defer closeBody(r)
var iwl *IncomingWebhooksWithCount
if r.StatusCode == http.StatusNotModified {
return iwl, BuildResponse(r), nil
}
if err := json.NewDecoder(r.Body).Decode(&iwl); err != nil {
return nil, nil, NewAppError("GetIncomingWebhooksWithCount", "api.unmarshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
return iwl, BuildResponse(r), nil
}
// GetIncomingWebhooksForTeam returns a page of incoming webhooks for a team. Page counting starts at 0.
func (c *Client4) GetIncomingWebhooksForTeam(ctx context.Context, teamId string, page int, perPage int, etag string) ([]*IncomingWebhook, *Response, error) {
query := fmt.Sprintf("?page=%v&per_page=%v&team_id=%v", page, perPage, teamId)

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

@@ -59,6 +59,11 @@ type IncomingWebhookRequest struct {
Priority *PostPriority `json:"priority"`
}
type IncomingWebhooksWithCount struct {
Webhooks []*IncomingWebhook `json:"incoming_webhooks"`
TotalCount int64 `json:"total_count"`
}
func (o *IncomingWebhook) IsValid() *AppError {
if !IsValidId(o.Id) {
return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.id.app_error", nil, "", http.StatusBadRequest)