0

Remove unnecessary var data in log messages. Closes #1640

This commit is contained in:
Gabe Kangas 2022-02-25 15:22:52 -08:00
parent 1c02ed291b
commit 6796998124
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
7 changed files with 14 additions and 24 deletions

View File

@ -38,7 +38,7 @@ func WebfingerHandler(w http.ResponseWriter, r *http.Request) {
if _, valid := data.GetFederatedInboxMap()[user]; !valid {
// User is not valid
w.WriteHeader(http.StatusNotFound)
log.Debugln("webfinger request rejected for user:", user)
log.Debugln("webfinger request rejected")
return
}

View File

@ -16,8 +16,6 @@ func InternalErrorHandler(w http.ResponseWriter, err error) {
return
}
log.Errorln(err)
w.WriteHeader(http.StatusInternalServerError)
if err := json.NewEncoder(w).Encode(j{"error": err.Error()}); err != nil {
InternalErrorHandler(w, err)

View File

@ -72,7 +72,7 @@ func GetCompatibleLogo(w http.ResponseWriter, r *http.Request) {
referrer = "an external site"
}
if !_hasWarnedSVGLogo {
log.Warnf("%s requested your logo. because many social networks do not support SVGs we returned a placeholder instead. change your current logo to a png or jpeg to be most compatible with external social networking sites.", referrer)
log.Warnf("an external site requested your logo. because many social networks do not support SVGs we returned a placeholder instead. change your current logo to a png or jpeg to be most compatible with external social networking sites.")
_hasWarnedSVGLogo = true
}
}

View File

@ -18,7 +18,7 @@ func createWebhooksTable() {
"url" string NOT NULL,
"events" TEXT NOT NULL,
"timestamp" DATETIME DEFAULT CURRENT_TIMESTAMP,
"last_used" DATETIME
"last_used" DATETIME
);`
stmt, err := _db.Prepare(createTableSQL)
@ -33,7 +33,7 @@ func createWebhooksTable() {
// InsertWebhook will add a new webhook to the database.
func InsertWebhook(url string, events []models.EventType) (int, error) {
log.Traceln("Adding new webhook:", url)
log.Traceln("Adding new webhook")
eventsString := strings.Join(events, ",")
@ -66,7 +66,7 @@ func InsertWebhook(url string, events []models.EventType) (int, error) {
// DeleteWebhook will delete a webhook from the database.
func DeleteWebhook(id int) error {
log.Traceln("Deleting webhook:", id)
log.Traceln("Deleting webhook")
tx, err := _db.Begin()
if err != nil {
@ -109,7 +109,7 @@ func GetWebhooksForEvent(event models.EventType) []models.Webhook {
FROM split
WHERE rest <> '')
SELECT id, url, event
FROM split
FROM split
WHERE event <> ''
) AS webhook WHERE event IS "` + event + `"`

View File

@ -162,15 +162,13 @@ func (s *S3Storage) Save(filePath string, retryCount int) (string, error) {
}
response, err := s.uploader.Upload(uploadInput)
if err != nil {
log.Traceln("error uploading:", filePath, err.Error())
log.Traceln("error uploading segment", err.Error())
if retryCount < 4 {
log.Traceln("Retrying...")
return s.Save(filePath, retryCount+1)
}
log.Warnln("Giving up on", filePath, err)
return "", fmt.Errorf("Giving up on %s", filePath)
}
@ -192,7 +190,6 @@ func (s *S3Storage) connectAWS() *session.Session {
S3ForcePathStyle: aws.Bool(s.s3ForcePathStyle),
},
)
if err != nil {
log.Panicln(err)
}

View File

@ -42,7 +42,7 @@ var validAccessTokenScopes = []string{
// InsertExternalAPIUser will add a new API user to the database.
func InsertExternalAPIUser(token string, name string, color int, scopes []string) error {
log.Traceln("Adding new API user:", name)
log.Traceln("Adding new API user")
_datastore.DbLock.Lock()
defer _datastore.DbLock.Unlock()
@ -55,7 +55,6 @@ func InsertExternalAPIUser(token string, name string, color int, scopes []string
return err
}
stmt, err := tx.Prepare("INSERT INTO users(id, access_token, display_name, display_color, scopes, type, previous_names) values(?, ?, ?, ?, ?, ?, ?)")
if err != nil {
return err
}
@ -74,7 +73,7 @@ func InsertExternalAPIUser(token string, name string, color int, scopes []string
// DeleteExternalAPIUser will delete a token from the database.
func DeleteExternalAPIUser(token string) error {
log.Traceln("Deleting access token:", token)
log.Traceln("Deleting access token")
_datastore.DbLock.Lock()
defer _datastore.DbLock.Unlock()
@ -84,7 +83,6 @@ func DeleteExternalAPIUser(token string) error {
return err
}
stmt, err := tx.Prepare("UPDATE users SET disabled_at = ? WHERE access_token = ?")
if err != nil {
return err
}
@ -113,7 +111,7 @@ func GetExternalAPIUserForAccessTokenAndScope(token string, scope string) (*Exte
// so we can efficiently find if a token supports a single scope.
// This is SQLite specific, so if we ever support other database
// backends we need to support other methods.
var query = `SELECT id, access_token, scopes, display_name, display_color, created_at, last_used FROM (
query := `SELECT id, access_token, scopes, display_name, display_color, created_at, last_used FROM (
WITH RECURSIVE split(id, access_token, scopes, display_name, display_color, created_at, last_used, disabled_at, scope, rest) AS (
SELECT id, access_token, scopes, display_name, display_color, created_at, last_used, disabled_at, '', scopes || ',' FROM users
UNION ALL
@ -122,8 +120,8 @@ func GetExternalAPIUserForAccessTokenAndScope(token string, scope string) (*Exte
substr(rest, instr(rest, ',')+1)
FROM split
WHERE rest <> '')
SELECT id, access_token, scopes, display_name, display_color, created_at, last_used, disabled_at, scope
FROM split
SELECT id, access_token, scopes, display_name, display_color, created_at, last_used, disabled_at, scope
FROM split
WHERE scope <> ''
ORDER BY access_token, scope
) AS token WHERE token.access_token = ? AND token.scope = ?`
@ -141,7 +139,6 @@ func GetIntegrationNameForAccessToken(token string) *string {
var name string
err := row.Scan(&name)
if err != nil {
log.Warnln(err)
return nil
@ -153,7 +150,7 @@ func GetIntegrationNameForAccessToken(token string) *string {
// GetExternalAPIUser will return all access tokens.
func GetExternalAPIUser() ([]ExternalAPIUser, error) { //nolint
// Get all messages sent within the past day
var query = "SELECT id, access_token, display_name, display_color, scopes, created_at, last_used FROM users WHERE type IS 'API' AND disabled_at IS NULL"
query := "SELECT id, access_token, display_name, display_color, scopes, created_at, last_used FROM users WHERE type IS 'API' AND disabled_at IS NULL"
rows, err := _datastore.DB.Query(query)
if err != nil {
@ -173,7 +170,6 @@ func SetExternalAPIUserAccessTokenAsUsed(token string) error {
return err
}
stmt, err := tx.Prepare("UPDATE users SET last_used = CURRENT_TIMESTAMP WHERE access_token = ?")
if err != nil {
return err
}
@ -256,7 +252,6 @@ func HasValidScopes(scopes []string) bool {
for _, scope := range scopes {
_, foundInSlice := utils.FindInSlice(validAccessTokenScopes, scope)
if !foundInSlice {
log.Errorln("Invalid scope", scope)
return false
}
}

View File

@ -41,7 +41,7 @@ func RequireAdminAuth(handler http.HandlerFunc) http.HandlerFunc {
if !ok || subtle.ConstantTimeCompare([]byte(user), []byte(username)) != 1 || subtle.ConstantTimeCompare([]byte(pass), []byte(password)) != 1 {
w.Header().Set("WWW-Authenticate", `Basic realm="`+realm+`"`)
http.Error(w, "Unauthorized", http.StatusUnauthorized)
log.Debugln("Failed authentication for", r.URL.Path, "from", r.RemoteAddr, r.UserAgent())
log.Debugln("Failed admin authentication")
return
}