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
This commit is contained in:
tobi
2021-10-04 15:24:19 +02:00
committed by GitHub
parent 9ce4234b9f
commit e04b187702
126 changed files with 1192 additions and 955 deletions

View File

@@ -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

View File

@@ -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"`
}

View File

@@ -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"`

View File

@@ -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, its [A-Za-z0-9_] in JavaScript, and [[:word:]] in Ruby.
// Ruby uses the POSIX character class (Letter | Mark | Decimal_Number | Connector_Punctuation).

View File

@@ -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"`

View File

@@ -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"`
}

View File

@@ -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"`

View File

@@ -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"`

View File

@@ -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

View File

@@ -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"`

View File

@@ -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

View File

@@ -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"`

View File

@@ -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"`

View File

@@ -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"`

View File

@@ -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

View File

@@ -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

View File

@@ -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