diff options
| author | 2021-10-04 15:24:19 +0200 | |
|---|---|---|
| committer | 2021-10-04 15:24:19 +0200 | |
| commit | e04b187702acb0c9908237a35b3a9857e2167b3f (patch) | |
| tree | 29839b8d5bbc28d34aba759a48dd7b005f1444f5 /internal/api | |
| parent | Follow request auto approval (#259) (diff) | |
| download | gotosocial-e04b187702acb0c9908237a35b3a9857e2167b3f.tar.xz | |
Refactor/tidy (#261)
* tidy up streaming
* cut down code duplication
* test get followers/following
* test streaming processor
* fix some test models
* add TimeMustParse
* fix uri / url typo
* make trace logging less verbose
* make logging more consistent
* disable quote on logging
* remove context.Background
* remove many extraneous mastodon references
* regenerate swagger
* don't log query on no rows result
* log latency first for easier reading
Diffstat (limited to 'internal/api')
36 files changed, 86 insertions, 179 deletions
| diff --git a/internal/api/client/account/accountupdate.go b/internal/api/client/account/accountupdate.go index 9a377f3b8..35eaaad6f 100644 --- a/internal/api/client/account/accountupdate.go +++ b/internal/api/client/account/accountupdate.go @@ -139,7 +139,7 @@ func (m *Module) AccountUpdateCredentialsPATCHHandler(c *gin.Context) {  		return  	} -	l.Tracef("conversion successful, returning OK and mastosensitive account %+v", acctSensitive) +	l.Tracef("conversion successful, returning OK and apisensitive account %+v", acctSensitive)  	c.JSON(http.StatusOK, acctSensitive)  } diff --git a/internal/api/client/admin/emojicreate.go b/internal/api/client/admin/emojicreate.go index 019298976..38928a9d8 100644 --- a/internal/api/client/admin/emojicreate.go +++ b/internal/api/client/admin/emojicreate.go @@ -111,14 +111,14 @@ func (m *Module) emojiCreatePOSTHandler(c *gin.Context) {  		return  	} -	mastoEmoji, err := m.processor.AdminEmojiCreate(c.Request.Context(), authed, form) +	apiEmoji, err := m.processor.AdminEmojiCreate(c.Request.Context(), authed, form)  	if err != nil {  		l.Debugf("error creating emoji: %s", err)  		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})  		return  	} -	c.JSON(http.StatusOK, mastoEmoji) +	c.JSON(http.StatusOK, apiEmoji)  }  func validateCreateEmoji(form *model.EmojiCreateRequest) error { diff --git a/internal/api/client/app/appcreate.go b/internal/api/client/app/appcreate.go index d233841b0..e4cbc32d0 100644 --- a/internal/api/client/app/appcreate.go +++ b/internal/api/client/app/appcreate.go @@ -101,12 +101,11 @@ func (m *Module) AppsPOSTHandler(c *gin.Context) {  		return  	} -	mastoApp, err := m.processor.AppCreate(c.Request.Context(), authed, form) +	apiApp, err := m.processor.AppCreate(c.Request.Context(), authed, form)  	if err != nil {  		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})  		return  	} -	// done, return the new app information per the spec here: https://docs.joinmastodon.org/methods/apps/ -	c.JSON(http.StatusOK, mastoApp) +	c.JSON(http.StatusOK, apiApp)  } diff --git a/internal/api/client/auth/auth_test.go b/internal/api/client/auth/auth_test.go index 295c0e964..bd4ff27fd 100644 --- a/internal/api/client/auth/auth_test.go +++ b/internal/api/client/auth/auth_test.go @@ -124,7 +124,7 @@ func (suite *AuthTestSuite) SetupTest() {  		}  	} -	suite.oauthServer = oauth.New(suite.db, log) +	suite.oauthServer = oauth.New(context.Background(), suite.db, log)  	if err := suite.db.Put(context.Background(), suite.testAccount); err != nil {  		logrus.Panicf("could not insert test account into db: %s", err) diff --git a/internal/api/client/auth/authorize.go b/internal/api/client/auth/authorize.go index d7ea65cca..972853687 100644 --- a/internal/api/client/auth/authorize.go +++ b/internal/api/client/auth/authorize.go @@ -35,7 +35,7 @@ import (  // AuthorizeGETHandler should be served as GET at https://example.org/oauth/authorize  // The idea here is to present an oauth authorize page to the user, with a button -// that they have to click to accept. See here: https://docs.joinmastodon.org/methods/apps/oauth/#authorize-a-user +// that they have to click to accept.  func (m *Module) AuthorizeGETHandler(c *gin.Context) {  	l := m.log.WithField("func", "AuthorizeGETHandler")  	s := sessions.Default(c) @@ -122,7 +122,6 @@ func (m *Module) AuthorizeGETHandler(c *gin.Context) {  // AuthorizePOSTHandler should be served as POST at https://example.org/oauth/authorize  // At this point we assume that the user has A) logged in and B) accepted that the app should act for them,  // so we should proceed with the authentication flow and generate an oauth token for them if we can. -// See here: https://docs.joinmastodon.org/methods/apps/oauth/#authorize-a-user  func (m *Module) AuthorizePOSTHandler(c *gin.Context) {  	l := m.log.WithField("func", "AuthorizePOSTHandler")  	s := sessions.Default(c) diff --git a/internal/api/client/auth/token.go b/internal/api/client/auth/token.go index 7e590aa1f..f9009767e 100644 --- a/internal/api/client/auth/token.go +++ b/internal/api/client/auth/token.go @@ -36,7 +36,6 @@ type tokenBody struct {  // TokenPOSTHandler should be served as a POST at https://example.org/oauth/token  // The idea here is to serve an oauth access token to a user, which can be used for authorizing against non-public APIs. -// See https://docs.joinmastodon.org/methods/apps/oauth/#obtain-a-token  func (m *Module) TokenPOSTHandler(c *gin.Context) {  	l := m.log.WithField("func", "TokenPOSTHandler")  	l.Trace("entered TokenPOSTHandler") diff --git a/internal/api/client/auth/util.go b/internal/api/client/auth/util.go index 48fe4748a..14c38e667 100644 --- a/internal/api/client/auth/util.go +++ b/internal/api/client/auth/util.go @@ -1,3 +1,21 @@ +/* +   GoToSocial +   Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org + +   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/>. +*/ +  package auth  import ( @@ -7,10 +25,6 @@ import (  func (m *Module) clearSession(s sessions.Session) {  	s.Clear() -	// newOptions := router.SessionOptions(m.config) -	// newOptions.MaxAge = -1 // instruct browser to delete cookie immediately -	// s.Options(newOptions) -  	if err := s.Save(); err != nil {  		panic(err)  	} diff --git a/internal/api/client/media/mediacreate.go b/internal/api/client/media/mediacreate.go index 58d076ea6..68b25039c 100644 --- a/internal/api/client/media/mediacreate.go +++ b/internal/api/client/media/mediacreate.go @@ -108,14 +108,14 @@ func (m *Module) MediaCreatePOSTHandler(c *gin.Context) {  	}  	l.Debug("calling processor media create func") -	mastoAttachment, err := m.processor.MediaCreate(c.Request.Context(), authed, form) +	apiAttachment, err := m.processor.MediaCreate(c.Request.Context(), authed, form)  	if err != nil {  		l.Debugf("error creating attachment: %s", err)  		c.JSON(http.StatusUnprocessableEntity, gin.H{"error": err.Error()})  		return  	} -	c.JSON(http.StatusOK, mastoAttachment) +	c.JSON(http.StatusOK, apiAttachment)  }  func validateCreateMedia(form *model.AttachmentRequest, config *config.MediaConfig) error { diff --git a/internal/api/client/status/statusboost.go b/internal/api/client/status/statusboost.go index 094e56ac0..6a1ccde28 100644 --- a/internal/api/client/status/statusboost.go +++ b/internal/api/client/status/statusboost.go @@ -87,12 +87,12 @@ func (m *Module) StatusBoostPOSTHandler(c *gin.Context) {  		return  	} -	mastoStatus, errWithCode := m.processor.StatusBoost(c.Request.Context(), authed, targetStatusID) +	apiStatus, errWithCode := m.processor.StatusBoost(c.Request.Context(), authed, targetStatusID)  	if errWithCode != nil {  		l.Debugf("error processing status boost: %s", errWithCode.Error())  		c.JSON(errWithCode.Code(), gin.H{"error": errWithCode.Safe()})  		return  	} -	c.JSON(http.StatusOK, mastoStatus) +	c.JSON(http.StatusOK, apiStatus)  } diff --git a/internal/api/client/status/statusboostedby.go b/internal/api/client/status/statusboostedby.go index 908c3ff10..a1446aef7 100644 --- a/internal/api/client/status/statusboostedby.go +++ b/internal/api/client/status/statusboostedby.go @@ -84,12 +84,12 @@ func (m *Module) StatusBoostedByGETHandler(c *gin.Context) {  		return  	} -	mastoAccounts, err := m.processor.StatusBoostedBy(c.Request.Context(), authed, targetStatusID) +	apiAccounts, err := m.processor.StatusBoostedBy(c.Request.Context(), authed, targetStatusID)  	if err != nil {  		l.Debugf("error processing status boosted by request: %s", err)  		c.JSON(http.StatusBadRequest, gin.H{"error": "bad request"})  		return  	} -	c.JSON(http.StatusOK, mastoAccounts) +	c.JSON(http.StatusOK, apiAccounts)  } diff --git a/internal/api/client/status/statuscreate.go b/internal/api/client/status/statuscreate.go index c8ea019d2..cae11ebdb 100644 --- a/internal/api/client/status/statuscreate.go +++ b/internal/api/client/status/statuscreate.go @@ -101,14 +101,14 @@ func (m *Module) StatusCreatePOSTHandler(c *gin.Context) {  		return  	} -	mastoStatus, err := m.processor.StatusCreate(c.Request.Context(), authed, form) +	apiStatus, err := m.processor.StatusCreate(c.Request.Context(), authed, form)  	if err != nil {  		l.Debugf("error processing status create: %s", err)  		c.JSON(http.StatusBadRequest, gin.H{"error": "bad request"})  		return  	} -	c.JSON(http.StatusOK, mastoStatus) +	c.JSON(http.StatusOK, apiStatus)  }  func validateCreateStatus(form *model.AdvancedStatusCreateForm, config *config.StatusesConfig) error { diff --git a/internal/api/client/status/statuscreate_test.go b/internal/api/client/status/statuscreate_test.go index 060d96dad..084f1a6f4 100644 --- a/internal/api/client/status/statuscreate_test.go +++ b/internal/api/client/status/statuscreate_test.go @@ -121,7 +121,7 @@ func (suite *StatusCreateTestSuite) TestPostNewStatus() {  	assert.Equal(suite.T(), "hello hello", statusReply.SpoilerText)  	assert.Equal(suite.T(), "<p>this is a brand new status! <a href=\"http://localhost:8080/tags/helloworld\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>helloworld</span></a></p>", statusReply.Content)  	assert.True(suite.T(), statusReply.Sensitive) -	assert.Equal(suite.T(), model.VisibilityPrivate, statusReply.Visibility) // even though we set this status to mutuals only, it should serialize to private, because masto has no idea about mutuals_only +	assert.Equal(suite.T(), model.VisibilityPrivate, statusReply.Visibility) // even though we set this status to mutuals only, it should serialize to private, because the mastodon api has no idea about mutuals_only  	assert.Len(suite.T(), statusReply.Tags, 1)  	assert.Equal(suite.T(), model.Tag{  		Name: "helloworld", @@ -202,12 +202,12 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithEmoji() {  	assert.Equal(suite.T(), "<p>here is a rainbow emoji a few times! :rainbow: :rainbow: :rainbow:<br>here's an emoji that isn't in the db: :test_emoji:</p>", statusReply.Content)  	assert.Len(suite.T(), statusReply.Emojis, 1) -	mastoEmoji := statusReply.Emojis[0] +	apiEmoji := statusReply.Emojis[0]  	gtsEmoji := testrig.NewTestEmojis()["rainbow"] -	assert.Equal(suite.T(), gtsEmoji.Shortcode, mastoEmoji.Shortcode) -	assert.Equal(suite.T(), gtsEmoji.ImageURL, mastoEmoji.URL) -	assert.Equal(suite.T(), gtsEmoji.ImageStaticURL, mastoEmoji.StaticURL) +	assert.Equal(suite.T(), gtsEmoji.Shortcode, apiEmoji.Shortcode) +	assert.Equal(suite.T(), gtsEmoji.ImageURL, apiEmoji.URL) +	assert.Equal(suite.T(), gtsEmoji.ImageStaticURL, apiEmoji.StaticURL)  }  // Try to reply to a status that doesn't exist @@ -326,12 +326,12 @@ func (suite *StatusCreateTestSuite) TestAttachNewMediaSuccess() {  	gtsAttachment, err := suite.db.GetAttachmentByID(context.Background(), statusResponse.MediaAttachments[0].ID)  	assert.NoError(suite.T(), err) -	// convert it to a masto attachment -	gtsAttachmentAsMasto, err := suite.tc.AttachmentToMasto(context.Background(), gtsAttachment) +	// convert it to a api attachment +	gtsAttachmentAsapi, err := suite.tc.AttachmentToAPIAttachment(context.Background(), gtsAttachment)  	assert.NoError(suite.T(), err)  	// compare it with what we have now -	assert.EqualValues(suite.T(), statusResponse.MediaAttachments[0], gtsAttachmentAsMasto) +	assert.EqualValues(suite.T(), statusResponse.MediaAttachments[0], gtsAttachmentAsapi)  	// the status id of the attachment should now be set to the id of the status we just created  	assert.Equal(suite.T(), statusResponse.ID, gtsAttachment.StatusID) diff --git a/internal/api/client/status/statusdelete.go b/internal/api/client/status/statusdelete.go index 9a67c45ba..1914a1a07 100644 --- a/internal/api/client/status/statusdelete.go +++ b/internal/api/client/status/statusdelete.go @@ -86,7 +86,7 @@ func (m *Module) StatusDELETEHandler(c *gin.Context) {  		return  	} -	mastoStatus, err := m.processor.StatusDelete(c.Request.Context(), authed, targetStatusID) +	apiStatus, err := m.processor.StatusDelete(c.Request.Context(), authed, targetStatusID)  	if err != nil {  		l.Debugf("error processing status delete: %s", err)  		c.JSON(http.StatusBadRequest, gin.H{"error": "bad request"}) @@ -94,10 +94,10 @@ func (m *Module) StatusDELETEHandler(c *gin.Context) {  	}  	// the status was already gone/never existed -	if mastoStatus == nil { +	if apiStatus == nil {  		c.JSON(http.StatusNotFound, gin.H{"error": "Record not found"})  		return  	} -	c.JSON(http.StatusOK, mastoStatus) +	c.JSON(http.StatusOK, apiStatus)  } diff --git a/internal/api/client/status/statusfave.go b/internal/api/client/status/statusfave.go index 94a8f9380..94d930989 100644 --- a/internal/api/client/status/statusfave.go +++ b/internal/api/client/status/statusfave.go @@ -83,12 +83,12 @@ func (m *Module) StatusFavePOSTHandler(c *gin.Context) {  		return  	} -	mastoStatus, err := m.processor.StatusFave(c.Request.Context(), authed, targetStatusID) +	apiStatus, err := m.processor.StatusFave(c.Request.Context(), authed, targetStatusID)  	if err != nil {  		l.Debugf("error processing status fave: %s", err)  		c.JSON(http.StatusBadRequest, gin.H{"error": "bad request"})  		return  	} -	c.JSON(http.StatusOK, mastoStatus) +	c.JSON(http.StatusOK, apiStatus)  } diff --git a/internal/api/client/status/statusfavedby.go b/internal/api/client/status/statusfavedby.go index 7b8e19e20..4ed6e74ed 100644 --- a/internal/api/client/status/statusfavedby.go +++ b/internal/api/client/status/statusfavedby.go @@ -84,12 +84,12 @@ func (m *Module) StatusFavedByGETHandler(c *gin.Context) {  		return  	} -	mastoAccounts, err := m.processor.StatusFavedBy(c.Request.Context(), authed, targetStatusID) +	apiAccounts, err := m.processor.StatusFavedBy(c.Request.Context(), authed, targetStatusID)  	if err != nil {  		l.Debugf("error processing status faved by request: %s", err)  		c.JSON(http.StatusBadRequest, gin.H{"error": "bad request"})  		return  	} -	c.JSON(http.StatusOK, mastoAccounts) +	c.JSON(http.StatusOK, apiAccounts)  } diff --git a/internal/api/client/status/statusget.go b/internal/api/client/status/statusget.go index 39668288f..3c74b53c8 100644 --- a/internal/api/client/status/statusget.go +++ b/internal/api/client/status/statusget.go @@ -83,12 +83,12 @@ func (m *Module) StatusGETHandler(c *gin.Context) {  		return  	} -	mastoStatus, err := m.processor.StatusGet(c.Request.Context(), authed, targetStatusID) +	apiStatus, err := m.processor.StatusGet(c.Request.Context(), authed, targetStatusID)  	if err != nil {  		l.Debugf("error processing status get: %s", err)  		c.JSON(http.StatusBadRequest, gin.H{"error": "bad request"})  		return  	} -	c.JSON(http.StatusOK, mastoStatus) +	c.JSON(http.StatusOK, apiStatus)  } diff --git a/internal/api/client/status/statusget_test.go b/internal/api/client/status/statusget_test.go index 1c700aaa5..fa5f786cb 100644 --- a/internal/api/client/status/statusget_test.go +++ b/internal/api/client/status/statusget_test.go @@ -57,61 +57,6 @@ func (suite *StatusGetTestSuite) TearDownTest() {  	testrig.StandardStorageTeardown(suite.storage)  } -// Post a new status with some custom visibility settings -func (suite *StatusGetTestSuite) TestPostNewStatus() { - -	// t := suite.testTokens["local_account_1"] -	// oauthToken := oauth.PGTokenToOauthToken(t) - -	// // setup -	// recorder := httptest.NewRecorder() -	// ctx, _ := gin.CreateTestContext(recorder) -	// 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", basePath), nil) // the endpoint we're hitting -	// ctx.Request.Form = url.Values{ -	// 	"status":              {"this is a brand new status! #helloworld"}, -	// 	"spoiler_text":        {"hello hello"}, -	// 	"sensitive":           {"true"}, -	// 	"visibility_advanced": {"mutuals_only"}, -	// 	"likeable":            {"false"}, -	// 	"replyable":           {"false"}, -	// 	"federated":           {"false"}, -	// } -	// suite.statusModule.statusGETHandler(ctx) - -	// // check response - -	// // 1. we should have OK from our call to the function -	// suite.EqualValues(http.StatusOK, recorder.Code) - -	// result := recorder.Result() -	// defer result.Body.Close() -	// b, err := ioutil.ReadAll(result.Body) -	// assert.NoError(suite.T(), err) - -	// statusReply := &mastotypes.Status{} -	// err = json.Unmarshal(b, statusReply) -	// assert.NoError(suite.T(), err) - -	// assert.Equal(suite.T(), "hello hello", statusReply.SpoilerText) -	// assert.Equal(suite.T(), "this is a brand new status! #helloworld", statusReply.Content) -	// assert.True(suite.T(), statusReply.Sensitive) -	// assert.Equal(suite.T(), mastotypes.VisibilityPrivate, statusReply.Visibility) -	// assert.Len(suite.T(), statusReply.Tags, 1) -	// assert.Equal(suite.T(), mastotypes.Tag{ -	// 	Name: "helloworld", -	// 	URL:  "http://localhost:8080/tags/helloworld", -	// }, statusReply.Tags[0]) - -	// gtsTag := >smodel.Tag{} -	// err = suite.db.GetWhere("name", "helloworld", gtsTag) -	// assert.NoError(suite.T(), err) -	// assert.Equal(suite.T(), statusReply.Account.ID, gtsTag.FirstSeenFromAccountID) -} -  func TestStatusGetTestSuite(t *testing.T) {  	suite.Run(t, new(StatusGetTestSuite))  } diff --git a/internal/api/client/status/statusunboost.go b/internal/api/client/status/statusunboost.go index 8bb28fa50..f114dbd0c 100644 --- a/internal/api/client/status/statusunboost.go +++ b/internal/api/client/status/statusunboost.go @@ -84,12 +84,12 @@ func (m *Module) StatusUnboostPOSTHandler(c *gin.Context) {  		return  	} -	mastoStatus, errWithCode := m.processor.StatusUnboost(c.Request.Context(), authed, targetStatusID) +	apiStatus, errWithCode := m.processor.StatusUnboost(c.Request.Context(), authed, targetStatusID)  	if errWithCode != nil {  		l.Debugf("error processing status unboost: %s", errWithCode.Error())  		c.JSON(errWithCode.Code(), gin.H{"error": errWithCode.Safe()})  		return  	} -	c.JSON(http.StatusOK, mastoStatus) +	c.JSON(http.StatusOK, apiStatus)  } diff --git a/internal/api/client/status/statusunfave.go b/internal/api/client/status/statusunfave.go index 5a1074ca2..3689e1899 100644 --- a/internal/api/client/status/statusunfave.go +++ b/internal/api/client/status/statusunfave.go @@ -83,12 +83,12 @@ func (m *Module) StatusUnfavePOSTHandler(c *gin.Context) {  		return  	} -	mastoStatus, err := m.processor.StatusUnfave(c.Request.Context(), authed, targetStatusID) +	apiStatus, err := m.processor.StatusUnfave(c.Request.Context(), authed, targetStatusID)  	if err != nil {  		l.Debugf("error processing status unfave: %s", err)  		c.JSON(http.StatusBadRequest, gin.H{"error": "bad request"})  		return  	} -	c.JSON(http.StatusOK, mastoStatus) +	c.JSON(http.StatusOK, apiStatus)  } diff --git a/internal/api/model/conversation.go b/internal/api/model/conversation.go index b0568c17e..36da6aab5 100644 --- a/internal/api/model/conversation.go +++ b/internal/api/model/conversation.go @@ -18,7 +18,7 @@  package model -// Conversation represents a conversation with "direct message" visibility. See https://docs.joinmastodon.org/entities/conversation/ +// Conversation represents a conversation with "direct message" visibility.  type Conversation struct {  	// REQUIRED diff --git a/internal/api/model/error.go b/internal/api/model/error.go deleted file mode 100644 index f145d69f2..000000000 --- a/internal/api/model/error.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -   GoToSocial -   Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org - -   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/>. -*/ - -package model - -// Error represents an error message returned from the API. See https://docs.joinmastodon.org/entities/error/ -type Error struct { -	// REQUIRED - -	// The error message. -	Error string `json:"error"` - -	// OPTIONAL - -	// A longer description of the error, mainly provided with the OAuth API. -	ErrorDescription string `json:"error_description"` -} diff --git a/internal/api/model/featuredtag.go b/internal/api/model/featuredtag.go index 3df3fe4c9..a0ea536f9 100644 --- a/internal/api/model/featuredtag.go +++ b/internal/api/model/featuredtag.go @@ -18,7 +18,7 @@  package model -// FeaturedTag represents a hashtag that is featured on a profile. See https://docs.joinmastodon.org/entities/featuredtag/ +// FeaturedTag represents a hashtag that is featured on a profile.  type FeaturedTag struct {  	// The internal ID of the featured tag in the database.  	ID string `json:"id"` diff --git a/internal/api/model/filter.go b/internal/api/model/filter.go index 519922ba3..2b0b05e5c 100644 --- a/internal/api/model/filter.go +++ b/internal/api/model/filter.go @@ -18,7 +18,7 @@  package model -// Filter represents a user-defined filter for determining which statuses should not be shown to the user. See https://docs.joinmastodon.org/entities/filter/ +// Filter represents a user-defined filter for determining which statuses should not be shown to the user.  // If whole_word is true , client app should do:  // Define ‘word constituent character’ for your app. In the official implementation, it’s [A-Za-z0-9_] in JavaScript, and [[:word:]] in Ruby.  // Ruby uses the POSIX character class (Letter | Mark | Decimal_Number | Connector_Punctuation). diff --git a/internal/api/model/history.go b/internal/api/model/history.go index d8b4d6b4f..92b7d4d77 100644 --- a/internal/api/model/history.go +++ b/internal/api/model/history.go @@ -18,7 +18,7 @@  package model -// History represents daily usage history of a hashtag. See https://docs.joinmastodon.org/entities/history/ +// History represents daily usage history of a hashtag.  type History struct {  	// UNIX timestamp on midnight of the given day (string cast from integer).  	Day string `json:"day"` diff --git a/internal/api/model/identityproof.go b/internal/api/model/identityproof.go deleted file mode 100644 index 400835fca..000000000 --- a/internal/api/model/identityproof.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -   GoToSocial -   Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org - -   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/>. -*/ - -package model - -// IdentityProof represents a proof from an external identity provider. See https://docs.joinmastodon.org/entities/identityproof/ -type IdentityProof struct { -	// The name of the identity provider. -	Provider string `json:"provider"` -	// The account owner's username on the identity provider's service. -	ProviderUsername string `json:"provider_username"` -	// The account owner's profile URL on the identity provider. -	ProfileURL string `json:"profile_url"` -	// A link to a statement of identity proof, hosted by the identity provider. -	ProofURL string `json:"proof_url"` -	// When the identity proof was last updated. -	UpdatedAt string `json:"updated_at"` -} diff --git a/internal/api/model/list.go b/internal/api/model/list.go index 220cde59e..61dd199d0 100644 --- a/internal/api/model/list.go +++ b/internal/api/model/list.go @@ -18,7 +18,7 @@  package model -// List represents a list of some users that the authenticated user follows. See https://docs.joinmastodon.org/entities/list/ +// List represents a list of some users that the authenticated user follows.  type List struct {  	// The internal database ID of the list.  	ID string `json:"id"` diff --git a/internal/api/model/marker.go b/internal/api/model/marker.go index 1e39f1516..7705f499b 100644 --- a/internal/api/model/marker.go +++ b/internal/api/model/marker.go @@ -18,7 +18,7 @@  package model -// Marker represents the last read position within a user's timelines. See https://docs.joinmastodon.org/entities/marker/ +// Marker represents the last read position within a user's timelines.  type Marker struct {  	// Information about the user's position in the home timeline.  	Home *TimelineMarker `json:"home"` @@ -26,7 +26,7 @@ type Marker struct {  	Notifications *TimelineMarker `json:"notifications"`  } -// TimelineMarker contains information about a user's progress through a specific timeline. See https://docs.joinmastodon.org/entities/marker/ +// TimelineMarker contains information about a user's progress through a specific timeline.  type TimelineMarker struct {  	// The ID of the most recently viewed entity.  	LastReadID string `json:"last_read_id"` diff --git a/internal/api/model/notification.go b/internal/api/model/notification.go index 2163251b4..2f6d8e595 100644 --- a/internal/api/model/notification.go +++ b/internal/api/model/notification.go @@ -18,7 +18,7 @@  package model -// Notification represents a notification of an event relevant to the user. See https://docs.joinmastodon.org/entities/notification/ +// Notification represents a notification of an event relevant to the user.  type Notification struct {  	// REQUIRED diff --git a/internal/api/model/oauth.go b/internal/api/model/oauth.go index 10c150474..7ff58daef 100644 --- a/internal/api/model/oauth.go +++ b/internal/api/model/oauth.go @@ -19,7 +19,6 @@  package model  // OAuthAuthorize represents a request sent to https://example.org/oauth/authorize -// See here: https://docs.joinmastodon.org/methods/apps/oauth/  type OAuthAuthorize struct {  	// Forces the user to re-login, which is necessary for authorizing with multiple accounts from the same instance.  	ForceLogin string `form:"force_login" json:"force_login"` diff --git a/internal/api/model/preferences.go b/internal/api/model/preferences.go index 9e410091e..0ff50bbd7 100644 --- a/internal/api/model/preferences.go +++ b/internal/api/model/preferences.go @@ -18,7 +18,7 @@  package model -// Preferences represents a user's preferences. See https://docs.joinmastodon.org/entities/preferences/ +// Preferences represents a user's preferences.  type Preferences struct {  	// Default visibility for new posts.  	// 	public = Public post diff --git a/internal/api/model/pushsubscription.go b/internal/api/model/pushsubscription.go index f34c63374..a8dd69b97 100644 --- a/internal/api/model/pushsubscription.go +++ b/internal/api/model/pushsubscription.go @@ -18,7 +18,7 @@  package model -// PushSubscription represents a subscription to the push streaming server. See https://docs.joinmastodon.org/entities/pushsubscription/ +// PushSubscription represents a subscription to the push streaming server.  type PushSubscription struct {  	// The id of the push subscription in the database.  	ID string `json:"id"` diff --git a/internal/api/model/results.go b/internal/api/model/results.go index 1b2625a0d..266d2083b 100644 --- a/internal/api/model/results.go +++ b/internal/api/model/results.go @@ -18,7 +18,7 @@  package model -// Results represents the results of a search. See https://docs.joinmastodon.org/entities/results/ +// Results represents the results of a search.  type Results struct {  	// Accounts which match the given query  	Accounts []Account `json:"accounts"` diff --git a/internal/api/model/scheduledstatus.go b/internal/api/model/scheduledstatus.go index deafd22aa..38f70d96a 100644 --- a/internal/api/model/scheduledstatus.go +++ b/internal/api/model/scheduledstatus.go @@ -18,7 +18,7 @@  package model -// ScheduledStatus represents a status that will be published at a future scheduled date. See https://docs.joinmastodon.org/entities/scheduledstatus/ +// ScheduledStatus represents a status that will be published at a future scheduled date.  type ScheduledStatus struct {  	ID               string        `json:"id"`  	ScheduledAt      string        `json:"scheduled_at"` @@ -26,7 +26,7 @@ type ScheduledStatus struct {  	MediaAttachments []Attachment  `json:"media_attachments"`  } -// StatusParams represents parameters for a scheduled status. See https://docs.joinmastodon.org/entities/scheduledstatus/ +// StatusParams represents parameters for a scheduled status.  type StatusParams struct {  	Text          string   `json:"text"`  	InReplyToID   string   `json:"in_reply_to_id,omitempty"` diff --git a/internal/api/model/source.go b/internal/api/model/source.go index 441af71de..9e429a3ca 100644 --- a/internal/api/model/source.go +++ b/internal/api/model/source.go @@ -20,7 +20,6 @@ package model  // Source represents display or publishing preferences of user's own account.  // Returned as an additional entity when verifying and updated credentials, as an attribute of Account. -// See https://docs.joinmastodon.org/entities/source/  type Source struct {  	// The default post privacy to be used for new statuses.  	//    public = Public post diff --git a/internal/api/model/status.go b/internal/api/model/status.go index 8be1a4870..ff0cd2e80 100644 --- a/internal/api/model/status.go +++ b/internal/api/model/status.go @@ -177,7 +177,7 @@ const (  	VisibilityDirect Visibility = "direct"  ) -// AdvancedStatusCreateForm wraps the mastodon status create form along with the GTS advanced +// AdvancedStatusCreateForm wraps the mastodon-compatible status create form along with the GTS advanced  // visibility settings.  //  // swagger:model advancedStatusCreateForm diff --git a/internal/api/model/timeline.go b/internal/api/model/timeline.go index 52d920879..de50c16cb 100644 --- a/internal/api/model/timeline.go +++ b/internal/api/model/timeline.go @@ -1,3 +1,21 @@ +/* +   GoToSocial +   Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org + +   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/>. +*/ +  package model  // StatusTimelineResponse wraps a slice of statuses, ready to be serialized, along with the Link | 
