diff options
Diffstat (limited to 'internal/api/client')
80 files changed, 118 insertions, 96 deletions
diff --git a/internal/api/client/accounts/accountcreate.go b/internal/api/client/accounts/accountcreate.go index 473000f6d..061c66b57 100644 --- a/internal/api/client/accounts/accountcreate.go +++ b/internal/api/client/accounts/accountcreate.go @@ -107,7 +107,7 @@ func (m *Module) AccountCreatePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, ti) + apiutil.JSON(c, http.StatusOK, ti) } // validateNormalizeCreateAccount checks through all the necessary prerequisites for creating a new account, diff --git a/internal/api/client/accounts/accountdelete.go b/internal/api/client/accounts/accountdelete.go index 242902cab..947634f70 100644 --- a/internal/api/client/accounts/accountdelete.go +++ b/internal/api/client/accounts/accountdelete.go @@ -96,5 +96,7 @@ func (m *Module) AccountDeletePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusAccepted, gin.H{"message": "accepted"}) + apiutil.JSON(c, http.StatusAccepted, map[string]string{ + "message": "accepted", + }) } diff --git a/internal/api/client/accounts/accountget.go b/internal/api/client/accounts/accountget.go index 300efe46e..4c1b66a20 100644 --- a/internal/api/client/accounts/accountget.go +++ b/internal/api/client/accounts/accountget.go @@ -90,5 +90,5 @@ func (m *Module) AccountGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, acctInfo) + apiutil.JSON(c, http.StatusOK, acctInfo) } diff --git a/internal/api/client/accounts/accountupdate.go b/internal/api/client/accounts/accountupdate.go index 9c51f5924..ab731bd7e 100644 --- a/internal/api/client/accounts/accountupdate.go +++ b/internal/api/client/accounts/accountupdate.go @@ -170,7 +170,7 @@ func (m *Module) AccountUpdateCredentialsPATCHHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, acctSensitive) + apiutil.JSON(c, http.StatusOK, acctSensitive) } // fieldsAttributesFormBinding satisfies gin's binding.Binding interface. diff --git a/internal/api/client/accounts/accountverify.go b/internal/api/client/accounts/accountverify.go index 97a21e0d8..1799089ab 100644 --- a/internal/api/client/accounts/accountverify.go +++ b/internal/api/client/accounts/accountverify.go @@ -73,5 +73,5 @@ func (m *Module) AccountVerifyGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, acctSensitive) + apiutil.JSON(c, http.StatusOK, acctSensitive) } diff --git a/internal/api/client/accounts/block.go b/internal/api/client/accounts/block.go index ccf781849..24ff099a7 100644 --- a/internal/api/client/accounts/block.go +++ b/internal/api/client/accounts/block.go @@ -90,5 +90,5 @@ func (m *Module) AccountBlockPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, relationship) + apiutil.JSON(c, http.StatusOK, relationship) } diff --git a/internal/api/client/accounts/follow.go b/internal/api/client/accounts/follow.go index 260f647cc..2e6e79964 100644 --- a/internal/api/client/accounts/follow.go +++ b/internal/api/client/accounts/follow.go @@ -122,5 +122,5 @@ func (m *Module) AccountFollowPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, relationship) + apiutil.JSON(c, http.StatusOK, relationship) } diff --git a/internal/api/client/accounts/followers.go b/internal/api/client/accounts/followers.go index 2448bc50a..bedbcef24 100644 --- a/internal/api/client/accounts/followers.go +++ b/internal/api/client/accounts/followers.go @@ -151,5 +151,5 @@ func (m *Module) AccountFollowersGETHandler(c *gin.Context) { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/accounts/following.go b/internal/api/client/accounts/following.go index d106d6ea6..9a8e488b2 100644 --- a/internal/api/client/accounts/following.go +++ b/internal/api/client/accounts/following.go @@ -151,5 +151,5 @@ func (m *Module) AccountFollowingGETHandler(c *gin.Context) { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/accounts/lists.go b/internal/api/client/accounts/lists.go index 4ce1bf729..d42fdd3f9 100644 --- a/internal/api/client/accounts/lists.go +++ b/internal/api/client/accounts/lists.go @@ -93,5 +93,5 @@ func (m *Module) AccountListsGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, lists) + apiutil.JSON(c, http.StatusOK, lists) } diff --git a/internal/api/client/accounts/lookup.go b/internal/api/client/accounts/lookup.go index 4b31ea6cc..f6bd97657 100644 --- a/internal/api/client/accounts/lookup.go +++ b/internal/api/client/accounts/lookup.go @@ -89,5 +89,5 @@ func (m *Module) AccountLookupGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, account) + apiutil.JSON(c, http.StatusOK, account) } diff --git a/internal/api/client/accounts/note.go b/internal/api/client/accounts/note.go index 9a0667875..29ea01c9a 100644 --- a/internal/api/client/accounts/note.go +++ b/internal/api/client/accounts/note.go @@ -104,5 +104,5 @@ func (m *Module) AccountNotePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, relationship) + apiutil.JSON(c, http.StatusOK, relationship) } diff --git a/internal/api/client/accounts/relationships.go b/internal/api/client/accounts/relationships.go index 591ae7684..dfe8c1721 100644 --- a/internal/api/client/accounts/relationships.go +++ b/internal/api/client/accounts/relationships.go @@ -106,5 +106,5 @@ func (m *Module) AccountRelationshipsGETHandler(c *gin.Context) { relationships = append(relationships, *r) } - c.JSON(http.StatusOK, relationships) + apiutil.JSON(c, http.StatusOK, relationships) } diff --git a/internal/api/client/accounts/search.go b/internal/api/client/accounts/search.go index c10fb2960..183fc1347 100644 --- a/internal/api/client/accounts/search.go +++ b/internal/api/client/accounts/search.go @@ -162,5 +162,5 @@ func (m *Module) AccountSearchGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, results) + apiutil.JSON(c, http.StatusOK, results) } diff --git a/internal/api/client/accounts/statuses.go b/internal/api/client/accounts/statuses.go index 867788501..870a96891 100644 --- a/internal/api/client/accounts/statuses.go +++ b/internal/api/client/accounts/statuses.go @@ -241,5 +241,6 @@ func (m *Module) AccountStatusesGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/accounts/unblock.go b/internal/api/client/accounts/unblock.go index 882a3b2f1..e8144711e 100644 --- a/internal/api/client/accounts/unblock.go +++ b/internal/api/client/accounts/unblock.go @@ -91,5 +91,6 @@ func (m *Module) AccountUnblockPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, relationship) + apiutil.JSON(c, http.StatusOK, relationship) + } diff --git a/internal/api/client/accounts/unfollow.go b/internal/api/client/accounts/unfollow.go index 4edc9ccea..9eb66aed3 100644 --- a/internal/api/client/accounts/unfollow.go +++ b/internal/api/client/accounts/unfollow.go @@ -91,5 +91,5 @@ func (m *Module) AccountUnfollowPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, relationship) + apiutil.JSON(c, http.StatusOK, relationship) } diff --git a/internal/api/client/admin/accountaction.go b/internal/api/client/admin/accountaction.go index 91186ae73..89bcf644e 100644 --- a/internal/api/client/admin/accountaction.go +++ b/internal/api/client/admin/accountaction.go @@ -124,5 +124,7 @@ func (m *Module) AccountActionPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, gin.H{"message": "OK"}) + apiutil.JSON(c, http.StatusOK, map[string]string{ + "message": "OK", + }) } diff --git a/internal/api/client/admin/domainkeysexpire.go b/internal/api/client/admin/domainkeysexpire.go index 73a811dd4..10a7597a4 100644 --- a/internal/api/client/admin/domainkeysexpire.go +++ b/internal/api/client/admin/domainkeysexpire.go @@ -132,7 +132,9 @@ func (m *Module) DomainKeysExpirePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusAccepted, &apimodel.AdminActionResponse{ActionID: actionID}) + apiutil.JSON(c, http.StatusOK, &apimodel.AdminActionResponse{ + ActionID: actionID, + }) } func validateDomainKeysExpire(form *apimodel.DomainKeysExpireRequest) error { diff --git a/internal/api/client/admin/domainpermission.go b/internal/api/client/admin/domainpermission.go index 203eddc8b..05319086f 100644 --- a/internal/api/client/admin/domainpermission.go +++ b/internal/api/client/admin/domainpermission.go @@ -122,7 +122,7 @@ func (m *Module) createDomainPermissions( return } - c.JSON(http.StatusOK, domainBlock) + apiutil.JSON(c, http.StatusOK, domainBlock) return } @@ -158,7 +158,7 @@ func (m *Module) createDomainPermissions( domainPerms = append(domainPerms, entry.Resource) } - c.JSON(http.StatusOK, domainPerms) + apiutil.JSON(c, http.StatusOK, domainPerms) } // deleteDomainPermission deletes a single domain permission (block or allow). @@ -200,7 +200,7 @@ func (m *Module) deleteDomainPermission( return } - c.JSON(http.StatusOK, domainPerm) + apiutil.JSON(c, http.StatusOK, domainPerm) } // getDomainPermission gets a single domain permission (block or allow). @@ -248,7 +248,7 @@ func (m *Module) getDomainPermission( return } - c.JSON(http.StatusOK, domainPerm) + apiutil.JSON(c, http.StatusOK, domainPerm) } // getDomainPermissions gets all domain permissions of the given type (block, allow). @@ -290,5 +290,5 @@ func (m *Module) getDomainPermissions( return } - c.JSON(http.StatusOK, domainPerm) + apiutil.JSON(c, http.StatusOK, domainPerm) } diff --git a/internal/api/client/admin/emailtest.go b/internal/api/client/admin/emailtest.go index 5c5330679..8f274e226 100644 --- a/internal/api/client/admin/emailtest.go +++ b/internal/api/client/admin/emailtest.go @@ -116,5 +116,7 @@ func (m *Module) EmailTestPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusAccepted, gin.H{"status": "test email sent"}) + apiutil.JSON(c, http.StatusAccepted, map[string]string{ + "status": "test email sent", + }) } diff --git a/internal/api/client/admin/emojicategoriesget.go b/internal/api/client/admin/emojicategoriesget.go index 9597f789c..2c097c6df 100644 --- a/internal/api/client/admin/emojicategoriesget.go +++ b/internal/api/client/admin/emojicategoriesget.go @@ -89,5 +89,5 @@ func (m *Module) EmojiCategoriesGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, categories) + apiutil.JSON(c, http.StatusOK, categories) } diff --git a/internal/api/client/admin/emojicreate.go b/internal/api/client/admin/emojicreate.go index e98ef754e..d916a76c1 100644 --- a/internal/api/client/admin/emojicreate.go +++ b/internal/api/client/admin/emojicreate.go @@ -131,7 +131,7 @@ func (m *Module) EmojiCreatePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, apiEmoji) + apiutil.JSON(c, http.StatusOK, apiEmoji) } func validateCreateEmoji(form *apimodel.EmojiCreateRequest) error { diff --git a/internal/api/client/admin/emojidelete.go b/internal/api/client/admin/emojidelete.go index 8d388a409..b5cf72daf 100644 --- a/internal/api/client/admin/emojidelete.go +++ b/internal/api/client/admin/emojidelete.go @@ -105,5 +105,5 @@ func (m *Module) EmojiDELETEHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, emoji) + apiutil.JSON(c, http.StatusOK, emoji) } diff --git a/internal/api/client/admin/emojiget.go b/internal/api/client/admin/emojiget.go index 349747b6b..710094551 100644 --- a/internal/api/client/admin/emojiget.go +++ b/internal/api/client/admin/emojiget.go @@ -95,5 +95,5 @@ func (m *Module) EmojiGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, emoji) + apiutil.JSON(c, http.StatusOK, emoji) } diff --git a/internal/api/client/admin/emojisget.go b/internal/api/client/admin/emojisget.go index c0ae90004..212401117 100644 --- a/internal/api/client/admin/emojisget.go +++ b/internal/api/client/admin/emojisget.go @@ -206,5 +206,6 @@ func (m *Module) EmojisGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/admin/emojiupdate.go b/internal/api/client/admin/emojiupdate.go index 49f8c3414..f531f36f9 100644 --- a/internal/api/client/admin/emojiupdate.go +++ b/internal/api/client/admin/emojiupdate.go @@ -161,7 +161,7 @@ func (m *Module) EmojiPATCHHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, emoji) + apiutil.JSON(c, http.StatusOK, emoji) } // do a first pass on the form here diff --git a/internal/api/client/admin/mediacleanup.go b/internal/api/client/admin/mediacleanup.go index 3ef3c1441..7a0ee4bd6 100644 --- a/internal/api/client/admin/mediacleanup.go +++ b/internal/api/client/admin/mediacleanup.go @@ -102,5 +102,5 @@ func (m *Module) MediaCleanupPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, remoteCacheDays) + apiutil.JSON(c, http.StatusOK, remoteCacheDays) } diff --git a/internal/api/client/admin/mediarefetch.go b/internal/api/client/admin/mediarefetch.go index 2c57d3b95..1c0da6dea 100644 --- a/internal/api/client/admin/mediarefetch.go +++ b/internal/api/client/admin/mediarefetch.go @@ -88,5 +88,5 @@ func (m *Module) MediaRefetchPOSTHandler(c *gin.Context) { return } - c.Status(http.StatusAccepted) + apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.StatusAcceptedJSON) } diff --git a/internal/api/client/admin/reportget.go b/internal/api/client/admin/reportget.go index 55425f53a..f70ae8b54 100644 --- a/internal/api/client/admin/reportget.go +++ b/internal/api/client/admin/reportget.go @@ -98,5 +98,5 @@ func (m *Module) ReportGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, report) + apiutil.JSON(c, http.StatusOK, report) } diff --git a/internal/api/client/admin/reportresolve.go b/internal/api/client/admin/reportresolve.go index fdd4f8449..9c1c32afe 100644 --- a/internal/api/client/admin/reportresolve.go +++ b/internal/api/client/admin/reportresolve.go @@ -120,5 +120,5 @@ func (m *Module) ReportResolvePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, report) + apiutil.JSON(c, http.StatusOK, report) } diff --git a/internal/api/client/admin/reportsget.go b/internal/api/client/admin/reportsget.go index cffa578f4..394962f6b 100644 --- a/internal/api/client/admin/reportsget.go +++ b/internal/api/client/admin/reportsget.go @@ -176,5 +176,6 @@ func (m *Module) ReportsGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/admin/rulecreate.go b/internal/api/client/admin/rulecreate.go index 7792233f6..e838bff1e 100644 --- a/internal/api/client/admin/rulecreate.go +++ b/internal/api/client/admin/rulecreate.go @@ -108,7 +108,7 @@ func (m *Module) RulePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, apiRule) + apiutil.JSON(c, http.StatusOK, apiRule) } func validateCreateRule(form *apimodel.InstanceRuleCreateRequest) error { diff --git a/internal/api/client/admin/ruledelete.go b/internal/api/client/admin/ruledelete.go index 7281ed62e..dfa84615f 100644 --- a/internal/api/client/admin/ruledelete.go +++ b/internal/api/client/admin/ruledelete.go @@ -103,5 +103,5 @@ func (m *Module) RuleDELETEHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, apiRule) + apiutil.JSON(c, http.StatusOK, apiRule) } diff --git a/internal/api/client/admin/ruleget.go b/internal/api/client/admin/ruleget.go index 444820a3f..8281092fb 100644 --- a/internal/api/client/admin/ruleget.go +++ b/internal/api/client/admin/ruleget.go @@ -98,5 +98,5 @@ func (m *Module) RuleGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, rule) + apiutil.JSON(c, http.StatusOK, rule) } diff --git a/internal/api/client/admin/rulesget.go b/internal/api/client/admin/rulesget.go index 56f83866f..2cc9e0158 100644 --- a/internal/api/client/admin/rulesget.go +++ b/internal/api/client/admin/rulesget.go @@ -87,5 +87,5 @@ func (m *Module) RulesGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, resp) + apiutil.JSON(c, http.StatusOK, resp) } diff --git a/internal/api/client/admin/ruleupdate.go b/internal/api/client/admin/ruleupdate.go index 82ed41190..eafa3af34 100644 --- a/internal/api/client/admin/ruleupdate.go +++ b/internal/api/client/admin/ruleupdate.go @@ -123,5 +123,5 @@ func (m *Module) RulePATCHHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, apiRule) + apiutil.JSON(c, http.StatusOK, apiRule) } diff --git a/internal/api/client/apps/appcreate.go b/internal/api/client/apps/appcreate.go index ebbc462cd..8aa87c3b3 100644 --- a/internal/api/client/apps/appcreate.go +++ b/internal/api/client/apps/appcreate.go @@ -121,5 +121,5 @@ func (m *Module) AppsPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, apiApp) + apiutil.JSON(c, http.StatusOK, apiApp) } diff --git a/internal/api/client/blocks/blocksget.go b/internal/api/client/blocks/blocksget.go index 0761160bc..fe5104c61 100644 --- a/internal/api/client/blocks/blocksget.go +++ b/internal/api/client/blocks/blocksget.go @@ -142,5 +142,5 @@ func (m *Module) BlocksGETHandler(c *gin.Context) { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/bookmarks/bookmarksget.go b/internal/api/client/bookmarks/bookmarksget.go index 06aaaf578..17808642c 100644 --- a/internal/api/client/bookmarks/bookmarksget.go +++ b/internal/api/client/bookmarks/bookmarksget.go @@ -120,5 +120,6 @@ func (m *Module) BookmarksGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/customemojis/customemojisget.go b/internal/api/client/customemojis/customemojisget.go index f9a529114..be595afd7 100644 --- a/internal/api/client/customemojis/customemojisget.go +++ b/internal/api/client/customemojis/customemojisget.go @@ -71,5 +71,5 @@ func (m *Module) CustomEmojisGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, emojis) + apiutil.JSON(c, http.StatusOK, emojis) } diff --git a/internal/api/client/favourites/favouritesget.go b/internal/api/client/favourites/favouritesget.go index 112bbd856..3ba2f9fcf 100644 --- a/internal/api/client/favourites/favouritesget.go +++ b/internal/api/client/favourites/favouritesget.go @@ -137,5 +137,6 @@ func (m *Module) FavouritesGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/featuredtags/get.go b/internal/api/client/featuredtags/get.go index f4ba00a39..c1ee7ca2c 100644 --- a/internal/api/client/featuredtags/get.go +++ b/internal/api/client/featuredtags/get.go @@ -71,5 +71,5 @@ func (m *Module) FeaturedTagsGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, []interface{}{}) + apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray) } diff --git a/internal/api/client/filters/filtersget.go b/internal/api/client/filters/filtersget.go index 58ae23c32..38dd330a7 100644 --- a/internal/api/client/filters/filtersget.go +++ b/internal/api/client/filters/filtersget.go @@ -38,5 +38,5 @@ func (m *Module) FiltersGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, []string{}) + apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray) } diff --git a/internal/api/client/followrequests/authorize.go b/internal/api/client/followrequests/authorize.go index 707d3db26..406b54179 100644 --- a/internal/api/client/followrequests/authorize.go +++ b/internal/api/client/followrequests/authorize.go @@ -93,5 +93,5 @@ func (m *Module) FollowRequestAuthorizePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, relationship) + apiutil.JSON(c, http.StatusOK, relationship) } diff --git a/internal/api/client/followrequests/get.go b/internal/api/client/followrequests/get.go index af2f3741c..40cdceaea 100644 --- a/internal/api/client/followrequests/get.go +++ b/internal/api/client/followrequests/get.go @@ -139,5 +139,5 @@ func (m *Module) FollowRequestGETHandler(c *gin.Context) { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/followrequests/reject.go b/internal/api/client/followrequests/reject.go index 6514a615e..a8189b78a 100644 --- a/internal/api/client/followrequests/reject.go +++ b/internal/api/client/followrequests/reject.go @@ -91,5 +91,5 @@ func (m *Module) FollowRequestRejectPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, relationship) + apiutil.JSON(c, http.StatusOK, relationship) } diff --git a/internal/api/client/instance/instanceget.go b/internal/api/client/instance/instanceget.go index 57d47b902..6690e7e98 100644 --- a/internal/api/client/instance/instanceget.go +++ b/internal/api/client/instance/instanceget.go @@ -58,7 +58,7 @@ func (m *Module) InstanceInformationGETHandlerV1(c *gin.Context) { return } - c.JSON(http.StatusOK, instance) + apiutil.JSON(c, http.StatusOK, instance) } // InstanceInformationGETHandlerV2 swagger:operation GET /api/v2/instance instanceGetV2 @@ -93,5 +93,5 @@ func (m *Module) InstanceInformationGETHandlerV2(c *gin.Context) { return } - c.JSON(http.StatusOK, instance) + apiutil.JSON(c, http.StatusOK, instance) } diff --git a/internal/api/client/instance/instancepatch.go b/internal/api/client/instance/instancepatch.go index 885ad19c8..484579cf2 100644 --- a/internal/api/client/instance/instancepatch.go +++ b/internal/api/client/instance/instancepatch.go @@ -161,7 +161,7 @@ func (m *Module) InstanceUpdatePATCHHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, i) + apiutil.JSON(c, http.StatusOK, i) } func validateInstanceUpdate(form *apimodel.InstanceSettingsUpdateRequest) error { diff --git a/internal/api/client/instance/instancepatch_test.go b/internal/api/client/instance/instancepatch_test.go index 1f8b691be..0c270de21 100644 --- a/internal/api/client/instance/instancepatch_test.go +++ b/internal/api/client/instance/instancepatch_test.go @@ -78,8 +78,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch1() { "uri": "http://localhost:8080", "account_domain": "localhost:8080", "title": "Example Instance", - "description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", - "short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", + "description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", + "short_description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", "email": "someone@example.org", "version": "0.0.0-testrig", "languages": [ @@ -195,8 +195,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch2() { "uri": "http://localhost:8080", "account_domain": "localhost:8080", "title": "Geoff's Instance", - "description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", - "short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", + "description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", + "short_description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", "email": "admin@example.org", "version": "0.0.0-testrig", "languages": [ @@ -312,8 +312,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch3() { "uri": "http://localhost:8080", "account_domain": "localhost:8080", "title": "GoToSocial Testrig Instance", - "description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", - "short_description": "\u003cp\u003eThis is some html, which is \u003cem\u003eallowed\u003c/em\u003e in short descriptions.\u003c/p\u003e", + "description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", + "short_description": "<p>This is some html, which is <em>allowed</em> in short descriptions.</p>", "email": "admin@example.org", "version": "0.0.0-testrig", "languages": [ @@ -480,8 +480,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch6() { "uri": "http://localhost:8080", "account_domain": "localhost:8080", "title": "GoToSocial Testrig Instance", - "description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", - "short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", + "description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", + "short_description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", "email": "", "version": "0.0.0-testrig", "languages": [ @@ -619,8 +619,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() { "uri": "http://localhost:8080", "account_domain": "localhost:8080", "title": "GoToSocial Testrig Instance", - "description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", - "short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", + "description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", + "short_description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", "email": "admin@example.org", "version": "0.0.0-testrig", "languages": [ @@ -773,8 +773,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch9() { "uri": "http://localhost:8080", "account_domain": "localhost:8080", "title": "GoToSocial Testrig Instance", - "description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", - "short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e", + "description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", + "short_description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>", "email": "admin@example.org", "version": "0.0.0-testrig", "languages": [ diff --git a/internal/api/client/instance/instancepeersget.go b/internal/api/client/instance/instancepeersget.go index 05085bc0f..c278c0674 100644 --- a/internal/api/client/instance/instancepeersget.go +++ b/internal/api/client/instance/instancepeersget.go @@ -156,5 +156,5 @@ func (m *Module) InstancePeersGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, data) + apiutil.JSON(c, http.StatusOK, data) } diff --git a/internal/api/client/instance/instancerulesget.go b/internal/api/client/instance/instancerulesget.go index 5cc99ba41..9df1b8fbe 100644 --- a/internal/api/client/instance/instancerulesget.go +++ b/internal/api/client/instance/instancerulesget.go @@ -67,5 +67,5 @@ func (m *Module) InstanceRulesGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, resp) + apiutil.JSON(c, http.StatusOK, resp) } diff --git a/internal/api/client/lists/listaccounts.go b/internal/api/client/lists/listaccounts.go index 6feffb1e8..e1d340ebb 100644 --- a/internal/api/client/lists/listaccounts.go +++ b/internal/api/client/lists/listaccounts.go @@ -174,5 +174,6 @@ func (m *Module) ListAccountsGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/lists/listaccountsadd.go b/internal/api/client/lists/listaccountsadd.go index a2a74e475..6fb5eab3c 100644 --- a/internal/api/client/lists/listaccountsadd.go +++ b/internal/api/client/lists/listaccountsadd.go @@ -116,5 +116,5 @@ func (m *Module) ListAccountsPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, gin.H{}) + apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONObject) } diff --git a/internal/api/client/lists/listaccountsremove.go b/internal/api/client/lists/listaccountsremove.go index 2a89cb960..50e53a3a3 100644 --- a/internal/api/client/lists/listaccountsremove.go +++ b/internal/api/client/lists/listaccountsremove.go @@ -126,5 +126,5 @@ func (m *Module) ListAccountsDELETEHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, gin.H{}) + apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONObject) } diff --git a/internal/api/client/lists/listcreate.go b/internal/api/client/lists/listcreate.go index 1405aedd2..4228e5fff 100644 --- a/internal/api/client/lists/listcreate.go +++ b/internal/api/client/lists/listcreate.go @@ -102,5 +102,5 @@ func (m *Module) ListCreatePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, apiList) + apiutil.JSON(c, http.StatusOK, apiList) } diff --git a/internal/api/client/lists/listdelete.go b/internal/api/client/lists/listdelete.go index e0139b574..b03f21e5a 100644 --- a/internal/api/client/lists/listdelete.go +++ b/internal/api/client/lists/listdelete.go @@ -87,5 +87,5 @@ func (m *Module) ListDELETEHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, gin.H{}) + apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONObject) } diff --git a/internal/api/client/lists/listget.go b/internal/api/client/lists/listget.go index f8dc54eb1..34b21d28b 100644 --- a/internal/api/client/lists/listget.go +++ b/internal/api/client/lists/listget.go @@ -91,5 +91,5 @@ func (m *Module) ListGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, resp) + apiutil.JSON(c, http.StatusOK, resp) } diff --git a/internal/api/client/lists/listsget.go b/internal/api/client/lists/listsget.go index f16152a9d..6bfc3c883 100644 --- a/internal/api/client/lists/listsget.go +++ b/internal/api/client/lists/listsget.go @@ -77,5 +77,5 @@ func (m *Module) ListsGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, lists) + apiutil.JSON(c, http.StatusOK, lists) } diff --git a/internal/api/client/lists/listupdate.go b/internal/api/client/lists/listupdate.go index 97c0cc636..58a4cf1c4 100644 --- a/internal/api/client/lists/listupdate.go +++ b/internal/api/client/lists/listupdate.go @@ -148,5 +148,5 @@ func (m *Module) ListUpdatePUTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, apiList) + apiutil.JSON(c, http.StatusOK, apiList) } diff --git a/internal/api/client/markers/markersget.go b/internal/api/client/markers/markersget.go index eb403dcc6..9f4fc4270 100644 --- a/internal/api/client/markers/markersget.go +++ b/internal/api/client/markers/markersget.go @@ -84,7 +84,7 @@ func (m *Module) MarkersGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, marker) + apiutil.JSON(c, http.StatusOK, marker) } // parseMarkerNames turns a list of strings into a set of valid marker timeline names, or returns an error. diff --git a/internal/api/client/markers/markerspost.go b/internal/api/client/markers/markerspost.go index 3167becac..8fe40c798 100644 --- a/internal/api/client/markers/markerspost.go +++ b/internal/api/client/markers/markerspost.go @@ -106,5 +106,5 @@ func (m *Module) MarkersPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, marker) + apiutil.JSON(c, http.StatusOK, marker) } diff --git a/internal/api/client/media/mediacreate.go b/internal/api/client/media/mediacreate.go index d2264bb0d..daa2e5bb7 100644 --- a/internal/api/client/media/mediacreate.go +++ b/internal/api/client/media/mediacreate.go @@ -139,7 +139,7 @@ func (m *Module) MediaCreatePOSTHandler(c *gin.Context) { apiAttachment.URL = nil } - c.JSON(http.StatusOK, apiAttachment) + apiutil.JSON(c, http.StatusOK, apiAttachment) } func validateCreateMedia(form *apimodel.AttachmentRequest) error { diff --git a/internal/api/client/media/mediaget.go b/internal/api/client/media/mediaget.go index 431f73d65..8456f85d8 100644 --- a/internal/api/client/media/mediaget.go +++ b/internal/api/client/media/mediaget.go @@ -98,5 +98,5 @@ func (m *Module) MediaGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, attachment) + apiutil.JSON(c, http.StatusOK, attachment) } diff --git a/internal/api/client/media/mediaupdate.go b/internal/api/client/media/mediaupdate.go index 032cfd705..8378502e8 100644 --- a/internal/api/client/media/mediaupdate.go +++ b/internal/api/client/media/mediaupdate.go @@ -141,7 +141,7 @@ func (m *Module) MediaPUTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, attachment) + apiutil.JSON(c, http.StatusOK, attachment) } func validateUpdateMedia(form *apimodel.AttachmentUpdateRequest) error { diff --git a/internal/api/client/notifications/notificationget.go b/internal/api/client/notifications/notificationget.go index 98e32498b..551eeca39 100644 --- a/internal/api/client/notifications/notificationget.go +++ b/internal/api/client/notifications/notificationget.go @@ -83,5 +83,5 @@ func (m *Module) NotificationGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, resp) + apiutil.JSON(c, http.StatusOK, resp) } diff --git a/internal/api/client/notifications/notificationsclear.go b/internal/api/client/notifications/notificationsclear.go index 4b63db283..2d7da3c6b 100644 --- a/internal/api/client/notifications/notificationsclear.go +++ b/internal/api/client/notifications/notificationsclear.go @@ -75,5 +75,5 @@ func (m *Module) NotificationsClearPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, struct{}{}) + apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONObject) } diff --git a/internal/api/client/notifications/notificationsget.go b/internal/api/client/notifications/notificationsget.go index fd175a115..da43cffec 100644 --- a/internal/api/client/notifications/notificationsget.go +++ b/internal/api/client/notifications/notificationsget.go @@ -155,5 +155,6 @@ func (m *Module) NotificationsGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/polls/polls_get.go b/internal/api/client/polls/polls_get.go index 0b15c0ed1..fc89255e9 100644 --- a/internal/api/client/polls/polls_get.go +++ b/internal/api/client/polls/polls_get.go @@ -96,5 +96,5 @@ func (m *Module) PollGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, poll) + apiutil.JSON(c, http.StatusOK, poll) } diff --git a/internal/api/client/polls/polls_vote.go b/internal/api/client/polls/polls_vote.go index e5281b3fc..0ab5ac20c 100644 --- a/internal/api/client/polls/polls_vote.go +++ b/internal/api/client/polls/polls_vote.go @@ -117,7 +117,7 @@ func (m *Module) PollVotePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, poll) + apiutil.JSON(c, http.StatusOK, poll) } func bindChoices(c *gin.Context) ([]int, error) { diff --git a/internal/api/client/preferences/preferencesget.go b/internal/api/client/preferences/preferencesget.go index 2834134de..4a6cb4b55 100644 --- a/internal/api/client/preferences/preferencesget.go +++ b/internal/api/client/preferences/preferencesget.go @@ -87,5 +87,6 @@ func (m *Module) PreferencesGETHandler(c *gin.Context) { apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) return } - c.JSON(http.StatusOK, resp) + + apiutil.JSON(c, http.StatusOK, resp) } diff --git a/internal/api/client/reports/reportcreate.go b/internal/api/client/reports/reportcreate.go index a4fa01148..a34b8d52e 100644 --- a/internal/api/client/reports/reportcreate.go +++ b/internal/api/client/reports/reportcreate.go @@ -107,5 +107,5 @@ func (m *Module) ReportPOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, apiReport) + apiutil.JSON(c, http.StatusOK, apiReport) } diff --git a/internal/api/client/reports/reportget.go b/internal/api/client/reports/reportget.go index 0d5d16da2..4a9b06664 100644 --- a/internal/api/client/reports/reportget.go +++ b/internal/api/client/reports/reportget.go @@ -90,5 +90,5 @@ func (m *Module) ReportGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, report) + apiutil.JSON(c, http.StatusOK, report) } diff --git a/internal/api/client/reports/reportsget.go b/internal/api/client/reports/reportsget.go index e290608eb..ba47f1b8b 100644 --- a/internal/api/client/reports/reportsget.go +++ b/internal/api/client/reports/reportsget.go @@ -168,5 +168,6 @@ func (m *Module) ReportsGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/search/searchget.go b/internal/api/client/search/searchget.go index 2759feb5b..909c14f24 100644 --- a/internal/api/client/search/searchget.go +++ b/internal/api/client/search/searchget.go @@ -235,5 +235,5 @@ func (m *Module) SearchGETHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, results) + apiutil.JSON(c, http.StatusOK, results) } diff --git a/internal/api/client/timelines/home.go b/internal/api/client/timelines/home.go index 963096f59..a7e7717da 100644 --- a/internal/api/client/timelines/home.go +++ b/internal/api/client/timelines/home.go @@ -147,5 +147,6 @@ func (m *Module) HomeTimelineGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/timelines/list.go b/internal/api/client/timelines/list.go index 2e13e32cd..dc5f21424 100644 --- a/internal/api/client/timelines/list.go +++ b/internal/api/client/timelines/list.go @@ -145,5 +145,6 @@ func (m *Module) ListTimelineGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/timelines/public.go b/internal/api/client/timelines/public.go index 7b8acf1ca..8eb34edc7 100644 --- a/internal/api/client/timelines/public.go +++ b/internal/api/client/timelines/public.go @@ -158,5 +158,6 @@ func (m *Module) PublicTimelineGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/timelines/tag.go b/internal/api/client/timelines/tag.go index 58754705b..0d95a6c58 100644 --- a/internal/api/client/timelines/tag.go +++ b/internal/api/client/timelines/tag.go @@ -142,5 +142,6 @@ func (m *Module) TagTimelineGETHandler(c *gin.Context) { if resp.LinkHeader != "" { c.Header("Link", resp.LinkHeader) } - c.JSON(http.StatusOK, resp.Items) + + apiutil.JSON(c, http.StatusOK, resp.Items) } diff --git a/internal/api/client/user/passwordchange.go b/internal/api/client/user/passwordchange.go index 8a1487ac0..c2928e9e5 100644 --- a/internal/api/client/user/passwordchange.go +++ b/internal/api/client/user/passwordchange.go @@ -99,5 +99,5 @@ func (m *Module) PasswordChangePOSTHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, gin.H{"status": "OK"}) + apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.StatusOKJSON) } |