diff --git a/internal/api/client/accounts/accountupdate_test.go b/internal/api/client/accounts/accountupdate_test.go index 9ccb29302..95387f3d7 100644 --- a/internal/api/client/accounts/accountupdate_test.go +++ b/internal/api/client/accounts/accountupdate_test.go @@ -250,6 +250,48 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateCredentialsPATCHHandlerTwo suite.NotEmpty(dbZork.EmojiIDs) } +func (suite *AccountUpdateTestSuite) TestAccountUpdateCredentialsPATCHHandlerDiscoverable() { + requestBody, w, err := testrig.CreateMultipartFormData( + "", "", + map[string]string{ + "discoverable": "false", + }) + if err != nil { + panic(err) + } + bodyBytes := requestBody.Bytes() + recorder := httptest.NewRecorder() + ctx := suite.newContext(recorder, http.MethodPatch, bodyBytes, accounts.UpdateCredentialsPath, w.FormDataContentType()) + + // call the handler + suite.accountsModule.AccountUpdateCredentialsPATCHHandler(ctx) + + // 1. we should have OK because our request was valid + suite.Equal(http.StatusOK, recorder.Code) + + // 2. we should have no error message in the result body + result := recorder.Result() + defer result.Body.Close() + + // check the response + b, err := ioutil.ReadAll(result.Body) + suite.NoError(err) + + // unmarshal the returned account + apimodelAccount := &apimodel.Account{} + err = json.Unmarshal(b, apimodelAccount) + suite.NoError(err) + + // check the returned api model account + // fields should be updated + suite.False(apimodelAccount.Discoverable) + + // check the account in the database + dbZork, err := suite.db.GetAccountByID(context.Background(), apimodelAccount.ID) + suite.NoError(err) + suite.False(*dbZork.Discoverable) +} + func (suite *AccountUpdateTestSuite) TestAccountUpdateCredentialsPATCHHandlerWithMedia() { // set up the request // we're updating the header image, the display name, and the locked status of zork diff --git a/internal/api/client/admin/reportsget_test.go b/internal/api/client/admin/reportsget_test.go index 9bcc3dcd0..f35720011 100644 --- a/internal/api/client/admin/reportsget_test.go +++ b/internal/api/client/admin/reportsget_test.go @@ -168,6 +168,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -206,6 +207,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "acct": "1happyturtle", "display_name": "happy little turtle :3", "locked": true, + "discoverable": false, "bot": false, "created_at": "2022-06-04T13:12:00.000Z", "note": "\u003cp\u003ei post about things that concern me\u003c/p\u003e", @@ -246,6 +248,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -287,6 +290,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -341,6 +345,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "acct": "1happyturtle", "display_name": "happy little turtle :3", "locked": true, + "discoverable": false, "bot": false, "created_at": "2022-06-04T13:12:00.000Z", "note": "\u003cp\u003ei post about things that concern me\u003c/p\u003e", @@ -381,6 +386,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -427,6 +433,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -533,6 +540,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet2() { "acct": "1happyturtle", "display_name": "happy little turtle :3", "locked": true, + "discoverable": false, "bot": false, "created_at": "2022-06-04T13:12:00.000Z", "note": "\u003cp\u003ei post about things that concern me\u003c/p\u003e", @@ -573,6 +581,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet2() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -619,6 +628,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet2() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -725,6 +735,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet3() { "acct": "1happyturtle", "display_name": "happy little turtle :3", "locked": true, + "discoverable": false, "bot": false, "created_at": "2022-06-04T13:12:00.000Z", "note": "\u003cp\u003ei post about things that concern me\u003c/p\u003e", @@ -765,6 +776,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet3() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -811,6 +823,7 @@ func (suite *ReportsGetTestSuite) TestReportsGet3() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", diff --git a/internal/api/client/followrequests/get_test.go b/internal/api/client/followrequests/get_test.go index 5d7feb3bf..213c8b780 100644 --- a/internal/api/client/followrequests/get_test.go +++ b/internal/api/client/followrequests/get_test.go @@ -81,6 +81,7 @@ func (suite *GetTestSuite) TestGet() { "acct": "Some_User@example.org", "display_name": "some user", "locked": true, + "discoverable": true, "bot": false, "created_at": "2020-08-10T12:13:28.000Z", "note": "i'm a real son of a gun", diff --git a/internal/api/client/instance/instancepatch_test.go b/internal/api/client/instance/instancepatch_test.go index 8833014f0..9233bc2b9 100644 --- a/internal/api/client/instance/instancepatch_test.go +++ b/internal/api/client/instance/instancepatch_test.go @@ -135,6 +135,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch1() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -230,6 +231,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch2() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -325,6 +327,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch3() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -471,6 +474,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch6() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -589,6 +593,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -719,6 +724,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch9() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", diff --git a/internal/api/client/reports/reportget_test.go b/internal/api/client/reports/reportget_test.go index bfde5c9fd..01338d019 100644 --- a/internal/api/client/reports/reportget_test.go +++ b/internal/api/client/reports/reportget_test.go @@ -117,6 +117,7 @@ func (suite *ReportGetTestSuite) TestGetReport1() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", diff --git a/internal/api/client/reports/reportsget_test.go b/internal/api/client/reports/reportsget_test.go index e970d9c8f..fc143bcdd 100644 --- a/internal/api/client/reports/reportsget_test.go +++ b/internal/api/client/reports/reportsget_test.go @@ -140,6 +140,7 @@ func (suite *ReportsGetTestSuite) TestGetReports() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -226,6 +227,7 @@ func (suite *ReportsGetTestSuite) TestGetReports4() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -296,6 +298,7 @@ func (suite *ReportsGetTestSuite) TestGetReports6() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -350,6 +353,7 @@ func (suite *ReportsGetTestSuite) TestGetReports7() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", diff --git a/internal/api/model/account.go b/internal/api/model/account.go index 8199532ca..ddfe6cc3a 100644 --- a/internal/api/model/account.go +++ b/internal/api/model/account.go @@ -45,7 +45,7 @@ type Account struct { // Account manually approves follow requests. Locked bool `json:"locked"` // Account has opted into discovery features. - Discoverable bool `json:"discoverable,omitempty"` + Discoverable bool `json:"discoverable"` // Account identifies as a bot. Bot bool `json:"bot"` // When the account was created (ISO 8601 Datetime). diff --git a/internal/processing/streaming/notification_test.go b/internal/processing/streaming/notification_test.go index 7e711c873..f31c169e1 100644 --- a/internal/processing/streaming/notification_test.go +++ b/internal/processing/streaming/notification_test.go @@ -67,6 +67,7 @@ func (suite *NotificationTestSuite) TestStreamNotification() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 799ccb0c4..738155532 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -204,6 +204,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A Acct: acct, DisplayName: a.DisplayName, Locked: *a.Locked, + Discoverable: *a.Discoverable, Bot: *a.Bot, CreatedAt: util.FormatISO8601(a.CreatedAt), Note: a.Note, diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go index 0704fb555..5599e4e88 100644 --- a/internal/typeutils/internaltofrontend_test.go +++ b/internal/typeutils/internaltofrontend_test.go @@ -47,6 +47,7 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontend() { "acct": "the_mighty_zork", "display_name": "original zork (he/they)", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-20T11:09:18.000Z", "note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e", @@ -84,6 +85,7 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendWithEmojiStruct() "acct": "the_mighty_zork", "display_name": "original zork (he/they)", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-20T11:09:18.000Z", "note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e", @@ -129,6 +131,7 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendWithEmojiIDs() { "acct": "the_mighty_zork", "display_name": "original zork (he/they)", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-20T11:09:18.000Z", "note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e", @@ -170,6 +173,7 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendSensitive() { "acct": "the_mighty_zork", "display_name": "original zork (he/they)", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-20T11:09:18.000Z", "note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e", @@ -238,6 +242,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -350,6 +355,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownLanguage() "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -531,6 +537,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -637,6 +644,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -745,6 +753,7 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend1() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -787,6 +796,7 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend2() { "acct": "1happyturtle", "display_name": "happy little turtle :3", "locked": true, + "discoverable": false, "bot": false, "created_at": "2022-06-04T13:12:00.000Z", "note": "\u003cp\u003ei post about things that concern me\u003c/p\u003e", @@ -845,6 +855,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -883,6 +894,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "acct": "1happyturtle", "display_name": "happy little turtle :3", "locked": true, + "discoverable": false, "bot": false, "created_at": "2022-06-04T13:12:00.000Z", "note": "\u003cp\u003ei post about things that concern me\u003c/p\u003e", @@ -923,6 +935,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -964,6 +977,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "acct": "admin", "display_name": "", "locked": false, + "discoverable": true, "bot": false, "created_at": "2022-05-17T13:10:59.000Z", "note": "", @@ -1028,6 +1042,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "acct": "1happyturtle", "display_name": "happy little turtle :3", "locked": true, + "discoverable": false, "bot": false, "created_at": "2022-06-04T13:12:00.000Z", "note": "\u003cp\u003ei post about things that concern me\u003c/p\u003e", @@ -1068,6 +1083,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!", @@ -1114,6 +1130,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "acct": "foss_satan@fossbros-anonymous.io", "display_name": "big gerald", "locked": false, + "discoverable": true, "bot": false, "created_at": "2021-09-26T10:52:36.000Z", "note": "i post about like, i dunno, stuff, or whatever!!!!",