| 
									
										
										
										
											2023-03-12 16:00:57 +01:00
										 |  |  | // GoToSocial | 
					
						
							|  |  |  | // Copyright (C) GoToSocial Authors admin@gotosocial.org | 
					
						
							|  |  |  | // SPDX-License-Identifier: AGPL-3.0-or-later | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  | // it under the terms of the GNU Affero General Public License as published by | 
					
						
							|  |  |  | // the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  | // (at your option) any later version. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  | // GNU Affero General Public License for more details. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  | // along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-02 13:10:50 +01:00
										 |  |  | package statuses_test | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"net/http" | 
					
						
							|  |  |  | 	"net/http/httptest" | 
					
						
							|  |  |  | 	"strings" | 
					
						
							|  |  |  | 	"testing" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-26 15:34:10 +02:00
										 |  |  | 	"code.superseriousbusiness.org/gotosocial/internal/api/client/statuses" | 
					
						
							|  |  |  | 	"code.superseriousbusiness.org/gotosocial/internal/filter/visibility" | 
					
						
							|  |  |  | 	"code.superseriousbusiness.org/gotosocial/internal/gtsmodel" | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 	"github.com/gin-gonic/gin" | 
					
						
							|  |  |  | 	"github.com/stretchr/testify/suite" | 
					
						
							| 
									
										
										
										
											2023-01-02 13:10:50 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-26 15:34:10 +02:00
										 |  |  | 	apiutil "code.superseriousbusiness.org/gotosocial/internal/api/util" | 
					
						
							|  |  |  | 	"code.superseriousbusiness.org/gotosocial/internal/oauth" | 
					
						
							|  |  |  | 	"code.superseriousbusiness.org/gotosocial/testrig" | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type StatusFaveTestSuite struct { | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | 	StatusStandardTestSuite | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | func (suite *StatusFaveTestSuite) postStatusFave( | 
					
						
							|  |  |  | 	targetStatusID string, | 
					
						
							|  |  |  | 	app *gtsmodel.Application, | 
					
						
							|  |  |  | 	token *gtsmodel.Token, | 
					
						
							|  |  |  | 	user *gtsmodel.User, | 
					
						
							|  |  |  | 	account *gtsmodel.Account, | 
					
						
							|  |  |  | ) (string, *httptest.ResponseRecorder) { | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 	recorder := httptest.NewRecorder() | 
					
						
							| 
									
										
										
										
											2022-07-12 08:32:20 +01:00
										 |  |  | 	ctx, _ := testrig.CreateGinTestContext(recorder, nil) | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	ctx.Set(oauth.SessionAuthorizedApplication, app) | 
					
						
							|  |  |  | 	ctx.Set(oauth.SessionAuthorizedToken, oauth.DBTokenToToken(token)) | 
					
						
							|  |  |  | 	ctx.Set(oauth.SessionAuthorizedUser, user) | 
					
						
							|  |  |  | 	ctx.Set(oauth.SessionAuthorizedAccount, account) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	const pathBase = "http://localhost:8080/api" + statuses.FavouritePath | 
					
						
							|  |  |  | 	path := strings.ReplaceAll(pathBase, ":"+apiutil.IDKey, targetStatusID) | 
					
						
							|  |  |  | 	ctx.Request = httptest.NewRequest(http.MethodPost, path, nil) | 
					
						
							| 
									
										
										
										
											2021-12-11 17:50:00 +01:00
										 |  |  | 	ctx.Request.Header.Set("accept", "application/json") | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	// Populate target status ID. | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 	ctx.Params = gin.Params{ | 
					
						
							|  |  |  | 		gin.Param{ | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 			Key:   apiutil.IDKey, | 
					
						
							|  |  |  | 			Value: targetStatusID, | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	// Trigger handler. | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 	suite.statusModule.StatusFavePOSTHandler(ctx) | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	return suite.parseStatusResponse(recorder) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | // Fave a status we haven't faved yet. | 
					
						
							|  |  |  | func (suite *StatusFaveTestSuite) TestPostFave() { | 
					
						
							|  |  |  | 	var ( | 
					
						
							|  |  |  | 		targetStatus = suite.testStatuses["admin_account_status_2"] | 
					
						
							|  |  |  | 		app          = suite.testApplications["application_1"] | 
					
						
							|  |  |  | 		token        = suite.testTokens["local_account_1"] | 
					
						
							|  |  |  | 		user         = suite.testUsers["local_account_1"] | 
					
						
							|  |  |  | 		account      = suite.testAccounts["local_account_1"] | 
					
						
							|  |  |  | 	) | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	out, recorder := suite.postStatusFave( | 
					
						
							|  |  |  | 		targetStatus.ID, | 
					
						
							|  |  |  | 		app, | 
					
						
							|  |  |  | 		token, | 
					
						
							|  |  |  | 		user, | 
					
						
							|  |  |  | 		account, | 
					
						
							|  |  |  | 	) | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	// We should have OK from | 
					
						
							|  |  |  | 	// our call to the function. | 
					
						
							|  |  |  | 	suite.Equal(http.StatusOK, recorder.Code) | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	// Target status should now | 
					
						
							|  |  |  | 	// be "favourited" by us. | 
					
						
							|  |  |  | 	suite.Equal(`{ | 
					
						
							|  |  |  |   "account": "yeah this is my account, what about it punk", | 
					
						
							|  |  |  |   "application": { | 
					
						
							|  |  |  |     "name": "superseriousbusiness", | 
					
						
							|  |  |  |     "website": "https://superserious.business" | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   "bookmarked": false, | 
					
						
							|  |  |  |   "card": null, | 
					
						
							| 
									
										
										
										
											2025-03-07 15:04:34 +01:00
										 |  |  |   "content": "<p>🐕🐕🐕🐕🐕</p>", | 
					
						
							| 
									
										
										
										
											2025-03-06 11:31:52 -05:00
										 |  |  |   "content_type": "text/plain", | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  |   "created_at": "right the hell just now babyee", | 
					
						
							| 
									
										
										
										
											2024-12-05 13:35:07 +00:00
										 |  |  |   "edited_at": null, | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  |   "emojis": [], | 
					
						
							|  |  |  |   "favourited": true, | 
					
						
							|  |  |  |   "favourites_count": 1, | 
					
						
							|  |  |  |   "id": "ZZZZZZZZZZZZZZZZZZZZZZZZZZ", | 
					
						
							|  |  |  |   "in_reply_to_account_id": null, | 
					
						
							|  |  |  |   "in_reply_to_id": null, | 
					
						
							|  |  |  |   "interaction_policy": { | 
					
						
							|  |  |  |     "can_favourite": { | 
					
						
							|  |  |  |       "always": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							| 
									
										
										
										
											2025-05-13 14:48:11 +00:00
										 |  |  |       "automatic_approval": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |       "manual_approval": [], | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  |       "with_approval": [] | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     "can_reblog": { | 
					
						
							|  |  |  |       "always": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							| 
									
										
										
										
											2025-05-13 14:48:11 +00:00
										 |  |  |       "automatic_approval": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |       "manual_approval": [], | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  |       "with_approval": [] | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     "can_reply": { | 
					
						
							|  |  |  |       "always": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							| 
									
										
										
										
											2025-05-13 14:48:11 +00:00
										 |  |  |       "automatic_approval": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |       "manual_approval": [], | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  |       "with_approval": [] | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   "language": "en", | 
					
						
							|  |  |  |   "media_attachments": [], | 
					
						
							|  |  |  |   "mentions": [], | 
					
						
							|  |  |  |   "muted": false, | 
					
						
							|  |  |  |   "pinned": false, | 
					
						
							|  |  |  |   "poll": null, | 
					
						
							|  |  |  |   "reblog": null, | 
					
						
							|  |  |  |   "reblogged": false, | 
					
						
							|  |  |  |   "reblogs_count": 0, | 
					
						
							|  |  |  |   "replies_count": 0, | 
					
						
							|  |  |  |   "sensitive": true, | 
					
						
							|  |  |  |   "spoiler_text": "open to see some puppies", | 
					
						
							|  |  |  |   "tags": [], | 
					
						
							|  |  |  |   "text": "🐕🐕🐕🐕🐕", | 
					
						
							|  |  |  |   "uri": "http://localhost:8080/some/determinate/url", | 
					
						
							|  |  |  |   "url": "http://localhost:8080/some/determinate/url", | 
					
						
							|  |  |  |   "visibility": "public" | 
					
						
							|  |  |  | }`, out) | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | // Try to fave a status | 
					
						
							|  |  |  | // that's not faveable by us. | 
					
						
							| 
									
										
										
										
											2024-07-24 13:27:42 +02:00
										 |  |  | func (suite *StatusFaveTestSuite) TestPostUnfaveable() { | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	var ( | 
					
						
							|  |  |  | 		targetStatus = suite.testStatuses["local_account_1_status_3"] | 
					
						
							|  |  |  | 		app          = suite.testApplications["application_1"] | 
					
						
							|  |  |  | 		token        = suite.testTokens["admin_account"] | 
					
						
							|  |  |  | 		user         = suite.testUsers["admin_account"] | 
					
						
							|  |  |  | 		account      = suite.testAccounts["admin_account"] | 
					
						
							|  |  |  | 	) | 
					
						
							| 
									
										
										
										
											2024-07-24 13:27:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	out, recorder := suite.postStatusFave( | 
					
						
							|  |  |  | 		targetStatus.ID, | 
					
						
							|  |  |  | 		app, | 
					
						
							|  |  |  | 		token, | 
					
						
							|  |  |  | 		user, | 
					
						
							|  |  |  | 		account, | 
					
						
							|  |  |  | 	) | 
					
						
							| 
									
										
										
										
											2024-07-24 13:27:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	// We should have 403 from | 
					
						
							|  |  |  | 	// our call to the function. | 
					
						
							|  |  |  | 	suite.Equal(http.StatusForbidden, recorder.Code) | 
					
						
							| 
									
										
										
										
											2024-07-24 13:27:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	// We should get a helpful error. | 
					
						
							|  |  |  | 	suite.Equal(`{ | 
					
						
							|  |  |  |   "error": "Forbidden: you do not have permission to fave this status" | 
					
						
							|  |  |  | }`, out) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-24 13:27:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | // Fave a status that's pending approval by us. | 
					
						
							|  |  |  | func (suite *StatusFaveTestSuite) TestPostFaveImplicitAccept() { | 
					
						
							|  |  |  | 	var ( | 
					
						
							| 
									
										
										
										
											2025-05-22 12:26:11 +02:00
										 |  |  | 		ctx          = suite.T().Context() | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 		targetStatus = suite.testStatuses["admin_account_status_5"] | 
					
						
							|  |  |  | 		app          = suite.testApplications["application_1"] | 
					
						
							|  |  |  | 		token        = suite.testTokens["local_account_2"] | 
					
						
							|  |  |  | 		user         = suite.testUsers["local_account_2"] | 
					
						
							|  |  |  | 		account      = suite.testAccounts["local_account_2"] | 
					
						
							| 
									
										
										
										
											2024-09-28 20:47:46 +00:00
										 |  |  | 		visFilter    = visibility.NewFilter(&suite.state) | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	) | 
					
						
							| 
									
										
										
										
											2024-07-24 13:27:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-28 20:47:46 +00:00
										 |  |  | 	// Check visibility of status to public before posting fave. | 
					
						
							|  |  |  | 	visible, err := visFilter.StatusVisible(ctx, nil, targetStatus) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		suite.FailNow(err.Error()) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if visible { | 
					
						
							|  |  |  | 		suite.FailNow("status should not be visible yet") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	out, recorder := suite.postStatusFave( | 
					
						
							|  |  |  | 		targetStatus.ID, | 
					
						
							|  |  |  | 		app, | 
					
						
							|  |  |  | 		token, | 
					
						
							|  |  |  | 		user, | 
					
						
							|  |  |  | 		account, | 
					
						
							|  |  |  | 	) | 
					
						
							| 
									
										
										
										
											2024-07-24 13:27:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	// We should have OK from | 
					
						
							|  |  |  | 	// our call to the function. | 
					
						
							|  |  |  | 	suite.Equal(http.StatusOK, recorder.Code) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Target status should now | 
					
						
							|  |  |  | 	// be "favourited" by us. | 
					
						
							|  |  |  | 	suite.Equal(`{ | 
					
						
							|  |  |  |   "account": "yeah this is my account, what about it punk", | 
					
						
							|  |  |  |   "application": { | 
					
						
							|  |  |  |     "name": "superseriousbusiness", | 
					
						
							|  |  |  |     "website": "https://superserious.business" | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   "bookmarked": false, | 
					
						
							|  |  |  |   "card": null, | 
					
						
							|  |  |  |   "content": "<p>Hi <span class=\"h-card\"><a href=\"http://localhost:8080/@1happyturtle\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>1happyturtle</span></a></span>, can I reply?</p>", | 
					
						
							| 
									
										
										
										
											2025-03-06 11:31:52 -05:00
										 |  |  |   "content_type": "text/markdown", | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  |   "created_at": "right the hell just now babyee", | 
					
						
							| 
									
										
										
										
											2024-12-05 13:35:07 +00:00
										 |  |  |   "edited_at": null, | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  |   "emojis": [], | 
					
						
							|  |  |  |   "favourited": true, | 
					
						
							|  |  |  |   "favourites_count": 1, | 
					
						
							|  |  |  |   "id": "ZZZZZZZZZZZZZZZZZZZZZZZZZZ", | 
					
						
							|  |  |  |   "in_reply_to_account_id": "01F8MH5NBDF2MV7CTC4Q5128HF", | 
					
						
							|  |  |  |   "in_reply_to_id": "01F8MHC8VWDRBQR0N1BATDDEM5", | 
					
						
							|  |  |  |   "interaction_policy": { | 
					
						
							|  |  |  |     "can_favourite": { | 
					
						
							|  |  |  |       "always": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							| 
									
										
										
										
											2025-05-13 14:48:11 +00:00
										 |  |  |       "automatic_approval": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |       "manual_approval": [], | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  |       "with_approval": [] | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     "can_reblog": { | 
					
						
							|  |  |  |       "always": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							| 
									
										
										
										
											2025-05-13 14:48:11 +00:00
										 |  |  |       "automatic_approval": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |       "manual_approval": [], | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  |       "with_approval": [] | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     "can_reply": { | 
					
						
							|  |  |  |       "always": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							| 
									
										
										
										
											2025-05-13 14:48:11 +00:00
										 |  |  |       "automatic_approval": [ | 
					
						
							|  |  |  |         "public", | 
					
						
							|  |  |  |         "me" | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |       "manual_approval": [], | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  |       "with_approval": [] | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   "language": null, | 
					
						
							|  |  |  |   "media_attachments": [], | 
					
						
							|  |  |  |   "mentions": [ | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       "acct": "1happyturtle", | 
					
						
							|  |  |  |       "id": "ZZZZZZZZZZZZZZZZZZZZZZZZZZ", | 
					
						
							|  |  |  |       "url": "http://localhost:8080/@1happyturtle", | 
					
						
							|  |  |  |       "username": "1happyturtle" | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   ], | 
					
						
							|  |  |  |   "muted": false, | 
					
						
							|  |  |  |   "pinned": false, | 
					
						
							|  |  |  |   "poll": null, | 
					
						
							|  |  |  |   "reblog": null, | 
					
						
							|  |  |  |   "reblogged": false, | 
					
						
							|  |  |  |   "reblogs_count": 0, | 
					
						
							|  |  |  |   "replies_count": 0, | 
					
						
							|  |  |  |   "sensitive": false, | 
					
						
							|  |  |  |   "spoiler_text": "", | 
					
						
							|  |  |  |   "tags": [], | 
					
						
							|  |  |  |   "text": "Hi @1happyturtle, can I reply?", | 
					
						
							|  |  |  |   "uri": "http://localhost:8080/some/determinate/url", | 
					
						
							|  |  |  |   "url": "http://localhost:8080/some/determinate/url", | 
					
						
							| 
									
										
										
										
											2024-09-28 20:47:46 +00:00
										 |  |  |   "visibility": "public" | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | }`, out) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Target status should no | 
					
						
							|  |  |  | 	// longer be pending approval. | 
					
						
							|  |  |  | 	dbStatus, err := suite.state.DB.GetStatusByID( | 
					
						
							| 
									
										
										
										
											2024-09-28 20:47:46 +00:00
										 |  |  | 		ctx, | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 		targetStatus.ID, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		suite.FailNow(err.Error()) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	suite.False(*dbStatus.PendingApproval) | 
					
						
							| 
									
										
										
										
											2024-09-28 20:47:46 +00:00
										 |  |  | 	suite.NotEmpty(dbStatus.ApprovedByURI) | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// There should be an Accept | 
					
						
							|  |  |  | 	// stored for the target status. | 
					
						
							|  |  |  | 	intReq, err := suite.state.DB.GetInteractionRequestByInteractionURI( | 
					
						
							| 
									
										
										
										
											2024-09-28 20:47:46 +00:00
										 |  |  | 		ctx, targetStatus.URI, | 
					
						
							| 
									
										
										
										
											2024-09-23 14:42:19 +02:00
										 |  |  | 	) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		suite.FailNow(err.Error()) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	suite.NotZero(intReq.AcceptedAt) | 
					
						
							|  |  |  | 	suite.NotEmpty(intReq.URI) | 
					
						
							| 
									
										
										
										
											2024-09-28 20:47:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Check visibility of status to public after posting fave. | 
					
						
							|  |  |  | 	visible, err = visFilter.StatusVisible(ctx, nil, dbStatus) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		suite.FailNow(err.Error()) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if !visible { | 
					
						
							|  |  |  | 		suite.FailNow("status should be visible") | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-07-24 13:27:42 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-04-19 19:42:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | func TestStatusFaveTestSuite(t *testing.T) { | 
					
						
							|  |  |  | 	suite.Run(t, new(StatusFaveTestSuite)) | 
					
						
							|  |  |  | } |