summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-07-11 16:44:29 +0200
committerLibravatar GitHub <noreply@github.com>2024-07-11 15:44:29 +0100
commit5bc567196bf2204272950c525e8592e56057c3bd (patch)
tree24aec5e75d2a0208505da16ee2c55efd887d3e25 /internal/api
parent[bugfix] Don't throw error when parent statuses are missing (#2011) (#3088) (diff)
downloadgotosocial-5bc567196bf2204272950c525e8592e56057c3bd.tar.xz
[chore] Add interaction policy gtsmodels (#3075)
* [chore] introduce interaction policy gts models * update migration a smidge * fix copy paste typo * update migration * use int for InteractionType
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/client/statuses/statusboost_test.go73
-rw-r--r--internal/api/client/statuses/statuscreate.go18
-rw-r--r--internal/api/client/statuses/statuscreate_test.go3
-rw-r--r--internal/api/client/statuses/statusfave_test.go73
-rw-r--r--internal/api/client/statuses/statuspin_test.go3
-rw-r--r--internal/api/model/status.go6
6 files changed, 74 insertions, 102 deletions
diff --git a/internal/api/client/statuses/statusboost_test.go b/internal/api/client/statuses/statusboost_test.go
index ae7c364bf..3e6a5853d 100644
--- a/internal/api/client/statuses/statusboost_test.go
+++ b/internal/api/client/statuses/statusboost_test.go
@@ -173,42 +173,43 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() {
}
// try to boost a status that's not boostable / visible to us
-func (suite *StatusBoostTestSuite) TestPostUnboostable() {
- t := suite.testTokens["local_account_1"]
- oauthToken := oauth.DBTokenToToken(t)
-
- targetStatus := suite.testStatuses["local_account_2_status_4"]
-
- // setup
- recorder := httptest.NewRecorder()
- ctx, _ := testrig.CreateGinTestContext(recorder, nil)
- ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"])
- ctx.Set(oauth.SessionAuthorizedToken, oauthToken)
- ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_1"])
- ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"])
- ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080%s", strings.Replace(statuses.ReblogPath, ":id", targetStatus.ID, 1)), nil) // the endpoint we're hitting
- ctx.Request.Header.Set("accept", "application/json")
-
- // normally the router would populate these params from the path values,
- // but because we're calling the function directly, we need to set them manually.
- ctx.Params = gin.Params{
- gin.Param{
- Key: statuses.IDKey,
- Value: targetStatus.ID,
- },
- }
-
- suite.statusModule.StatusBoostPOSTHandler(ctx)
-
- // check response
- suite.Equal(http.StatusNotFound, recorder.Code) // we 404 unboostable statuses
-
- result := recorder.Result()
- defer result.Body.Close()
- b, err := ioutil.ReadAll(result.Body)
- suite.NoError(err)
- suite.Equal(`{"error":"Not Found"}`, string(b))
-}
+// TODO: sort this out with new interaction policies
+// func (suite *StatusBoostTestSuite) TestPostUnboostable() {
+// t := suite.testTokens["local_account_1"]
+// oauthToken := oauth.DBTokenToToken(t)
+
+// targetStatus := suite.testStatuses["local_account_2_status_4"]
+
+// // setup
+// recorder := httptest.NewRecorder()
+// ctx, _ := testrig.CreateGinTestContext(recorder, nil)
+// ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"])
+// ctx.Set(oauth.SessionAuthorizedToken, oauthToken)
+// ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_1"])
+// ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"])
+// ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080%s", strings.Replace(statuses.ReblogPath, ":id", targetStatus.ID, 1)), nil) // the endpoint we're hitting
+// ctx.Request.Header.Set("accept", "application/json")
+
+// // normally the router would populate these params from the path values,
+// // but because we're calling the function directly, we need to set them manually.
+// ctx.Params = gin.Params{
+// gin.Param{
+// Key: statuses.IDKey,
+// Value: targetStatus.ID,
+// },
+// }
+
+// suite.statusModule.StatusBoostPOSTHandler(ctx)
+
+// // check response
+// suite.Equal(http.StatusNotFound, recorder.Code) // we 404 unboostable statuses
+
+// result := recorder.Result()
+// defer result.Body.Close()
+// b, err := ioutil.ReadAll(result.Body)
+// suite.NoError(err)
+// suite.Equal(`{"error":"Not Found"}`, string(b))
+// }
// try to boost a status that's not visible to the user
func (suite *StatusBoostTestSuite) TestPostNotVisible() {
diff --git a/internal/api/client/statuses/statuscreate.go b/internal/api/client/statuses/statuscreate.go
index 5a9654195..7b30e0ee6 100644
--- a/internal/api/client/statuses/statuscreate.go
+++ b/internal/api/client/statuses/statuscreate.go
@@ -168,24 +168,6 @@ import (
// description: This status will be federated beyond the local timeline(s).
// in: formData
// type: boolean
-// -
-// name: boostable
-// x-go-name: Boostable
-// description: This status can be boosted/reblogged.
-// in: formData
-// type: boolean
-// -
-// name: replyable
-// x-go-name: Replyable
-// description: This status can be replied to.
-// in: formData
-// type: boolean
-// -
-// name: likeable
-// x-go-name: Likeable
-// description: This status can be liked/faved.
-// in: formData
-// type: boolean
//
// produces:
// - application/json
diff --git a/internal/api/client/statuses/statuscreate_test.go b/internal/api/client/statuses/statuscreate_test.go
index b49e72ead..94d91c8b9 100644
--- a/internal/api/client/statuses/statuscreate_test.go
+++ b/internal/api/client/statuses/statuscreate_test.go
@@ -67,9 +67,6 @@ func (suite *StatusCreateTestSuite) TestPostNewStatus() {
"spoiler_text": {"hello hello"},
"sensitive": {"true"},
"visibility": {string(apimodel.VisibilityMutualsOnly)},
- "likeable": {"false"},
- "replyable": {"false"},
- "federated": {"false"},
}
suite.statusModule.StatusCreatePOSTHandler(ctx)
diff --git a/internal/api/client/statuses/statusfave_test.go b/internal/api/client/statuses/statusfave_test.go
index ebe4603a8..5a35351e4 100644
--- a/internal/api/client/statuses/statusfave_test.go
+++ b/internal/api/client/statuses/statusfave_test.go
@@ -89,42 +89,43 @@ func (suite *StatusFaveTestSuite) TestPostFave() {
}
// try to fave a status that's not faveable
-func (suite *StatusFaveTestSuite) TestPostUnfaveable() {
- t := suite.testTokens["local_account_1"]
- oauthToken := oauth.DBTokenToToken(t)
-
- targetStatus := suite.testStatuses["local_account_2_status_3"] // this one is unlikeable and unreplyable
-
- // setup
- recorder := httptest.NewRecorder()
- ctx, _ := testrig.CreateGinTestContext(recorder, nil)
- ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"])
- ctx.Set(oauth.SessionAuthorizedToken, oauthToken)
- ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_1"])
- ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"])
- ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080%s", strings.Replace(statuses.FavouritePath, ":id", targetStatus.ID, 1)), nil) // the endpoint we're hitting
- ctx.Request.Header.Set("accept", "application/json")
-
- // normally the router would populate these params from the path values,
- // but because we're calling the function directly, we need to set them manually.
- ctx.Params = gin.Params{
- gin.Param{
- Key: statuses.IDKey,
- Value: targetStatus.ID,
- },
- }
-
- suite.statusModule.StatusFavePOSTHandler(ctx)
-
- // check response
- suite.EqualValues(http.StatusForbidden, recorder.Code)
-
- result := recorder.Result()
- defer result.Body.Close()
- b, err := ioutil.ReadAll(result.Body)
- assert.NoError(suite.T(), err)
- assert.Equal(suite.T(), `{"error":"Forbidden: status is not faveable"}`, string(b))
-}
+// TODO: replace this when interaction policies enforced.
+// func (suite *StatusFaveTestSuite) TestPostUnfaveable() {
+// t := suite.testTokens["local_account_1"]
+// oauthToken := oauth.DBTokenToToken(t)
+
+// targetStatus := suite.testStatuses["local_account_2_status_3"] // this one is unlikeable and unreplyable
+
+// // setup
+// recorder := httptest.NewRecorder()
+// ctx, _ := testrig.CreateGinTestContext(recorder, nil)
+// ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"])
+// ctx.Set(oauth.SessionAuthorizedToken, oauthToken)
+// ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_1"])
+// ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"])
+// ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080%s", strings.Replace(statuses.FavouritePath, ":id", targetStatus.ID, 1)), nil) // the endpoint we're hitting
+// ctx.Request.Header.Set("accept", "application/json")
+
+// // normally the router would populate these params from the path values,
+// // but because we're calling the function directly, we need to set them manually.
+// ctx.Params = gin.Params{
+// gin.Param{
+// Key: statuses.IDKey,
+// Value: targetStatus.ID,
+// },
+// }
+
+// suite.statusModule.StatusFavePOSTHandler(ctx)
+
+// // check response
+// suite.EqualValues(http.StatusForbidden, recorder.Code)
+
+// result := recorder.Result()
+// defer result.Body.Close()
+// b, err := ioutil.ReadAll(result.Body)
+// assert.NoError(suite.T(), err)
+// assert.Equal(suite.T(), `{"error":"Forbidden: status is not faveable"}`, string(b))
+// }
func TestStatusFaveTestSuite(t *testing.T) {
suite.Run(t, new(StatusFaveTestSuite))
diff --git a/internal/api/client/statuses/statuspin_test.go b/internal/api/client/statuses/statuspin_test.go
index 39909e6c4..e9b65bd37 100644
--- a/internal/api/client/statuses/statuspin_test.go
+++ b/internal/api/client/statuses/statuspin_test.go
@@ -183,9 +183,6 @@ func (suite *StatusPinTestSuite) TestPinStatusTooManyPins() {
AccountURI: testAccount.URI,
Visibility: gtsmodel.VisibilityPublic,
Federated: util.Ptr(true),
- Boostable: util.Ptr(true),
- Replyable: util.Ptr(true),
- Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote,
}
if err := suite.db.PutStatus(ctx, status); err != nil {
diff --git a/internal/api/model/status.go b/internal/api/model/status.go
index 9098cb59d..0d925d211 100644
--- a/internal/api/model/status.go
+++ b/internal/api/model/status.go
@@ -230,12 +230,6 @@ type AdvancedStatusCreateForm struct {
type AdvancedVisibilityFlagsForm struct {
// This status will be federated beyond the local timeline(s).
Federated *bool `form:"federated" json:"federated" xml:"federated"`
- // This status can be boosted/reblogged.
- Boostable *bool `form:"boostable" json:"boostable" xml:"boostable"`
- // This status can be replied to.
- Replyable *bool `form:"replyable" json:"replyable" xml:"replyable"`
- // This status can be liked/faved.
- Likeable *bool `form:"likeable" json:"likeable" xml:"likeable"`
}
// StatusContentType is the content type with which to parse the submitted status.