Skip to content

Commit

Permalink
chore(go): run better align against project
Browse files Browse the repository at this point in the history
To optimize struct field order. Closes #2870
  • Loading branch information
gabek committed Apr 16, 2023
1 parent deb1b67 commit a468557
Show file tree
Hide file tree
Showing 42 changed files with 236 additions and 224 deletions.
16 changes: 8 additions & 8 deletions activitypub/apmodels/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ import (

// ActivityPubActor represents a single actor in handling ActivityPub activity.
type ActivityPubActor struct {
// RequestObject is the actual follow request object.
RequestObject vocab.ActivityStreamsFollow
// W3IDSecurityV1PublicKey is the public key of the actor.
W3IDSecurityV1PublicKey vocab.W3IDSecurityV1PublicKeyProperty
// ActorIRI is the IRI of the remote actor.
ActorIri *url.URL
// FollowRequestIRI is the unique identifier of the follow request.
FollowRequestIri *url.URL
// Inbox is the inbox URL of the remote follower
Inbox *url.URL
// Image is the avatar image of the Actor.
Image *url.URL
// DisabledAt is the time, if any, this follower was blocked/removed.
DisabledAt *time.Time
// Name is the display name of the follower.
Name string
// Username is the account username of the remote actor.
Username string
// FullUsername is the username@account.tld representation of the user.
FullUsername string
// Image is the avatar image of the Actor.
Image *url.URL
// RequestObject is the actual follow request object.
RequestObject vocab.ActivityStreamsFollow
// W3IDSecurityV1PublicKey is the public key of the actor.
W3IDSecurityV1PublicKey vocab.W3IDSecurityV1PublicKeyProperty
// DisabledAt is the time, if any, this follower was blocked/removed.
DisabledAt *time.Time
}

// DeleteRequest represents a request for delete.
Expand Down
8 changes: 4 additions & 4 deletions activitypub/controllers/nodeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ func XNodeInfo2Controller(w http.ResponseWriter, r *http.Request) {
LocalComments int `json:"localComments"`
}
type response struct {
Organization Organization `json:"organization"`
Server Server `json:"server"`
Organization Organization `json:"organization"`
Version string `json:"version"`
Services Services `json:"services"`
Protocols []string `json:"protocols"`
Version string `json:"version"`
OpenRegistrations bool `json:"openRegistrations"`
Usage Usage `json:"usage"`
OpenRegistrations bool `json:"openRegistrations"`
}

if !data.GetFederationEnabled() {
Expand Down Expand Up @@ -224,9 +224,9 @@ func InstanceV1Controller(w http.ResponseWriter, r *http.Request) {
ShortDescription string `json:"short_description"`
Description string `json:"description"`
Version string `json:"version"`
Stats Stats `json:"stats"`
Thumbnail string `json:"thumbnail"`
Languages []string `json:"languages"`
Stats Stats `json:"stats"`
Registrations bool `json:"registrations"`
ApprovalRequired bool `json:"approval_required"`
InvitesEnabled bool `json:"invites_enabled"`
Expand Down
2 changes: 1 addition & 1 deletion auth/fediverse/fediverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (

// OTPRegistration represents a single OTP request.
type OTPRegistration struct {
Timestamp time.Time
UserID string
UserDisplayName string
Code string
Account string
Timestamp time.Time
}

// Key by access token to limit one OTP request for a person
Expand Down
10 changes: 5 additions & 5 deletions auth/indieauth/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import (

// Request represents a single in-flight IndieAuth request.
type Request struct {
UserID string
DisplayName string
CurrentAccessToken string
Timestamp time.Time
Endpoint *url.URL
Redirect *url.URL // Outbound redirect URL to continue auth flow
Callback *url.URL // Inbound URL to get auth flow results
Me *url.URL
UserID string
DisplayName string
CurrentAccessToken string
ClientID string
CodeVerifier string
CodeChallenge string
State string
Me *url.URL
Timestamp time.Time
}
2 changes: 1 addition & 1 deletion auth/indieauth/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
// ServerAuthRequest is n inbound request to authenticate against
// this Owncast instance.
type ServerAuthRequest struct {
Timestamp time.Time
ClientID string
RedirectURI string
CodeChallenge string
State string
Me string
Code string
Timestamp time.Time
}

// ServerProfile represents basic user-provided data about this Owncast instance.
Expand Down
37 changes: 21 additions & 16 deletions config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,37 @@ import (

// Defaults will hold default configuration values.
type Defaults struct {
Name string
Title string
PageBodyContent string

FederationGoLiveMessage string

Summary string
ServerWelcomeMessage string
Logo string
Tags []string
PageBodyContent string
YPServer string

Title string

DatabaseFilePath string
WebServerPort int
WebServerIP string
RTMPServerPort int
AdminPassword string
StreamKeys []models.StreamKey

YPEnabled bool
YPServer string
FederationUsername string
WebServerIP string
Name string
AdminPassword string
StreamKeys []models.StreamKey

SegmentLengthSeconds int
SegmentsInPlaylist int
StreamVariants []models.StreamOutputVariant
StreamVariants []models.StreamOutputVariant

FederationUsername string
FederationGoLiveMessage string
Tags []string
RTMPServerPort int
SegmentsInPlaylist int

SegmentLengthSeconds int
WebServerPort int

ChatEstablishedUserModeTimeDuration time.Duration

YPEnabled bool
}

// GetDefaults will return default configuration values.
Expand Down
2 changes: 1 addition & 1 deletion controllers/admin/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func GetWarnings(w http.ResponseWriter, r *http.Request) {
}

type logsResponse struct {
Time time.Time `json:"time"`
Message string `json:"message"`
Level string `json:"level"`
Time time.Time `json:"time"`
}

func fromEntry(e *logrus.Entry) logsResponse {
Expand Down
48 changes: 24 additions & 24 deletions controllers/admin/serverConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,27 @@ func GetServerConfig(w http.ResponseWriter, r *http.Request) {

type serverConfigAdminResponse struct {
InstanceDetails webConfigResponse `json:"instanceDetails"`
Notifications notificationsConfigResponse `json:"notifications"`
YP yp `json:"yp"`
FFmpegPath string `json:"ffmpegPath"`
AdminPassword string `json:"adminPassword"`
StreamKeys []models.StreamKey `json:"streamKeys"`
StreamKeyOverridden bool `json:"streamKeyOverridden"`
WebServerPort int `json:"webServerPort"`
SocketHostOverride string `json:"socketHostOverride,omitempty"`
WebServerIP string `json:"webServerIP"`
RTMPServerPort int `json:"rtmpServerPort"`
VideoCodec string `json:"videoCodec"`
S3 models.S3 `json:"s3"`
Federation federationConfigResponse `json:"federation"`
SupportedCodecs []string `json:"supportedCodecs"`
ExternalActions []models.ExternalAction `json:"externalActions"`
ForbiddenUsernames []string `json:"forbiddenUsernames"`
SuggestedUsernames []string `json:"suggestedUsernames"`
StreamKeys []models.StreamKey `json:"streamKeys"`
VideoSettings videoSettings `json:"videoSettings"`
YP yp `json:"yp"`
RTMPServerPort int `json:"rtmpServerPort"`
WebServerPort int `json:"webServerPort"`
ChatDisabled bool `json:"chatDisabled"`
ChatJoinMessagesEnabled bool `json:"chatJoinMessagesEnabled"`
ChatEstablishedUserMode bool `json:"chatEstablishedUserMode"`
ExternalActions []models.ExternalAction `json:"externalActions"`
SupportedCodecs []string `json:"supportedCodecs"`
VideoCodec string `json:"videoCodec"`
ForbiddenUsernames []string `json:"forbiddenUsernames"`
Federation federationConfigResponse `json:"federation"`
SuggestedUsernames []string `json:"suggestedUsernames"`
SocketHostOverride string `json:"socketHostOverride,omitempty"`
Notifications notificationsConfigResponse `json:"notifications"`
StreamKeyOverridden bool `json:"streamKeyOverridden"`
HideViewerCount bool `json:"hideViewerCount"`
}

Expand All @@ -129,35 +129,35 @@ type videoSettings struct {
}

type webConfigResponse struct {
Name string `json:"name"`
Summary string `json:"summary"`
AppearanceVariables map[string]string `json:"appearanceVariables"`
Version string `json:"version"`
WelcomeMessage string `json:"welcomeMessage"`
OfflineMessage string `json:"offlineMessage"`
Logo string `json:"logo"`
Tags []string `json:"tags"`
Version string `json:"version"`
NSFW bool `json:"nsfw"`
Name string `json:"name"`
ExtraPageContent string `json:"extraPageContent"`
StreamTitle string `json:"streamTitle"` // What's going on with the current stream
SocialHandles []models.SocialHandle `json:"socialHandles"`
CustomStyles string `json:"customStyles"`
CustomJavascript string `json:"customJavascript"`
AppearanceVariables map[string]string `json:"appearanceVariables"`
Summary string `json:"summary"`
Tags []string `json:"tags"`
SocialHandles []models.SocialHandle `json:"socialHandles"`
NSFW bool `json:"nsfw"`
}

type yp struct {
Enabled bool `json:"enabled"`
InstanceURL string `json:"instanceUrl"` // The public URL the directory should link to
YPServiceURL string `json:"-"` // The base URL to the YP API to register with (optional)
Enabled bool `json:"enabled"`
}

type federationConfigResponse struct {
Enabled bool `json:"enabled"`
IsPrivate bool `json:"isPrivate"`
Username string `json:"username"`
GoLiveMessage string `json:"goLiveMessage"`
ShowEngagement bool `json:"showEngagement"`
BlockedDomains []string `json:"blockedDomains"`
Enabled bool `json:"enabled"`
IsPrivate bool `json:"isPrivate"`
ShowEngagement bool `json:"showEngagement"`
}

type notificationsConfigResponse struct {
Expand Down
8 changes: 4 additions & 4 deletions controllers/admin/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ func Status(w http.ResponseWriter, r *http.Request) {
type adminStatusResponse struct {
Broadcaster *models.Broadcaster `json:"broadcaster"`
CurrentBroadcast *models.CurrentBroadcast `json:"currentBroadcast"`
Online bool `json:"online"`
Health *models.StreamHealthOverview `json:"health"`
StreamTitle string `json:"streamTitle"`
VersionNumber string `json:"versionNumber"`
ViewerCount int `json:"viewerCount"`
OverallPeakViewerCount int `json:"overallPeakViewerCount"`
SessionPeakViewerCount int `json:"sessionPeakViewerCount"`
StreamTitle string `json:"streamTitle"`
Health *models.StreamHealthOverview `json:"health"`
VersionNumber string `json:"versionNumber"`
Online bool `json:"online"`
}
20 changes: 10 additions & 10 deletions controllers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,37 @@ import (
)

type webConfigResponse struct {
Name string `json:"name"`
AppearanceVariables map[string]string `json:"appearanceVariables"`
Notifications notificationsConfigResponse `json:"notifications"`
CustomStyles string `json:"customStyles"`
Summary string `json:"summary"`
OfflineMessage string `json:"offlineMessage"`
Logo string `json:"logo"`
Tags []string `json:"tags"`
Version string `json:"version"`
NSFW bool `json:"nsfw"`
SocketHostOverride string `json:"socketHostOverride,omitempty"`
ExtraPageContent string `json:"extraPageContent"`
StreamTitle string `json:"streamTitle,omitempty"` // What's going on with the current stream
Name string `json:"name"`
Federation federationConfigResponse `json:"federation"`
SocialHandles []models.SocialHandle `json:"socialHandles"`
ChatDisabled bool `json:"chatDisabled"`
ExternalActions []models.ExternalAction `json:"externalActions"`
CustomStyles string `json:"customStyles"`
AppearanceVariables map[string]string `json:"appearanceVariables"`
Tags []string `json:"tags"`
MaxSocketPayloadSize int `json:"maxSocketPayloadSize"`
Federation federationConfigResponse `json:"federation"`
Notifications notificationsConfigResponse `json:"notifications"`
ChatDisabled bool `json:"chatDisabled"`
NSFW bool `json:"nsfw"`
Authentication authenticationConfigResponse `json:"authentication"`
HideViewerCount bool `json:"hideViewerCount"`
}

type federationConfigResponse struct {
Enabled bool `json:"enabled"`
Account string `json:"account,omitempty"`
FollowerCount int `json:"followerCount,omitempty"`
Enabled bool `json:"enabled"`
}

type browserNotificationsConfigResponse struct {
Enabled bool `json:"enabled"`
PublicKey string `json:"publicKey,omitempty"`
Enabled bool `json:"enabled"`
}

type notificationsConfigResponse struct {
Expand Down
6 changes: 3 additions & 3 deletions controllers/moderation/moderation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import (
// GetUserDetails returns the details of a chat user for moderators.
func GetUserDetails(w http.ResponseWriter, r *http.Request) {
type connectedClient struct {
Id uint `json:"id"`
MessageCount int `json:"messageCount"`
UserAgent string `json:"userAgent"`
ConnectedAt time.Time `json:"connectedAt"`
UserAgent string `json:"userAgent"`
Geo string `json:"geo,omitempty"`
Id uint `json:"id"`
MessageCount int `json:"messageCount"`
}

type response struct {
Expand Down
2 changes: 1 addition & 1 deletion controllers/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package controllers

// PaginatedResponse is a structure for returning a total count with results.
type PaginatedResponse struct {
Total int `json:"total"`
Results interface{} `json:"results"`
Total int `json:"total"`
}
4 changes: 2 additions & 2 deletions controllers/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ func getStatusResponse() webStatusResponse {
}

type webStatusResponse struct {
Online bool `json:"online"`
ViewerCount int `json:"viewerCount,omitempty"`
ServerTime time.Time `json:"serverTime"`
LastConnectTime *utils.NullTime `json:"lastConnectTime"`
LastDisconnectTime *utils.NullTime `json:"lastDisconnectTime"`

VersionNumber string `json:"versionNumber"`
StreamTitle string `json:"streamTitle"`
ViewerCount int `json:"viewerCount,omitempty"`
Online bool `json:"online"`
}
6 changes: 3 additions & 3 deletions controllers/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
)

type variantsSort struct {
Index int
Name string
IsVideoPassthrough bool
Index int
VideoBitrate int
IsVideoPassthrough bool
}

type variantsResponse struct {
Index int `json:"index"`
Name string `json:"name"`
Index int `json:"index"`
}

// GetVideoStreamOutputVariants will return the video variants available.
Expand Down
Loading

0 comments on commit a468557

Please sign in to comment.