Skip to content

Commit

Permalink
fixed typos and some linter suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Jan 23, 2024
1 parent 80d65a1 commit aabe820
Show file tree
Hide file tree
Showing 17 changed files with 6,827 additions and 6,818 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

- Added `TestMailer.SentMessages` field that holds all sent test app emails until cleanup.

- Optimized the cascade delete of records with multiple `relation`.

- Fixed the `admin` command error reporting.

- Minor Admin UI improvements (reduced the min table row height, added option to duplicate fields, added new TinyMCE codesample plugin languages, hide the collection sync settings when the `Settings.Meta.HideControls` is enabled, etc.)


Expand Down
2 changes: 1 addition & 1 deletion apis/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func InitApi(app core.App) (*echo.Echo, error) {
logRequest(app, c, apiErr)

if c.Response().Committed {
return // already commited
return // already committed
}

event := new(core.ApiErrorEvent)
Expand Down
2 changes: 1 addition & 1 deletion apis/record_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (api *recordAuthApi) authMethods(c echo.Context) error {

provider, err := auth.NewProviderByName(name)
if err != nil {
api.app.Logger().Debug("Missing or invalid provier name", slog.String("name", name))
api.app.Logger().Debug("Missing or invalid provider name", slog.String("name", name))
continue // skip provider
}

Expand Down
4 changes: 2 additions & 2 deletions apis/record_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ func RecordAuthResponse(
// EnrichRecord parses the request context and enrich the provided record:
// - expands relations (if defaultExpands and/or ?expand query param is set)
// - ensures that the emails of the auth record and its expanded auth relations
// are visibe only for the current logged admin, record owner or record with manage access
// are visible only for the current logged admin, record owner or record with manage access
func EnrichRecord(c echo.Context, dao *daos.Dao, record *models.Record, defaultExpands ...string) error {
return EnrichRecords(c, dao, []*models.Record{record}, defaultExpands...)
}

// EnrichRecords parses the request context and enriches the provided records:
// - expands relations (if defaultExpands and/or ?expand query param is set)
// - ensures that the emails of the auth records and their expanded auth relations
// are visibe only for the current logged admin, record owner or record with manage access
// are visible only for the current logged admin, record owner or record with manage access
func EnrichRecords(c echo.Context, dao *daos.Dao, records []*models.Record, defaultExpands ...string) error {
requestInfo := RequestInfo(c)

Expand Down
4 changes: 4 additions & 0 deletions cmd/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ func adminDeleteCommand(app core.App) *cobra.Command {
return errors.New("Invalid or missing email address.")
}

if !app.Dao().HasTable((&models.Admin{}).TableName()) {
return errors.New("Migration are not initialized yet. Please run 'migrate up' and try again.")
}

admin, err := app.Dao().FindAdminByEmail(args[0])
if err != nil {
color.Yellow("Admin %s is already deleted.", args[0])
Expand Down
3 changes: 2 additions & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"log"
"net/http"

Expand Down Expand Up @@ -43,7 +44,7 @@ func NewServeCommand(app core.App, showStartBanner bool) *cobra.Command {
CertificateDomains: args,
})

if err != http.ErrServerClosed {
if !errors.Is(err, http.ErrServerClosed) {
log.Fatalln(err)
}
},
Expand Down
18 changes: 9 additions & 9 deletions daos/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func New(db dbx.Builder) *Dao {
return NewMultiDB(db, db)
}

// New creates a new Dao instance with the provided dedicated
// NewMultiDB creates a new Dao instance with the provided dedicated
// async and sync db builders.
func NewMultiDB(concurrentDB, nonconcurrentDB dbx.Builder) *Dao {
return &Dao{
Expand Down Expand Up @@ -87,16 +87,16 @@ func (dao *Dao) Clone() *Dao {
// WithoutHooks returns a new Dao with the same configuration options
// as the current one, but without create/update/delete hooks.
func (dao *Dao) WithoutHooks() *Dao {
new := dao.Clone()
clone := dao.Clone()

new.BeforeCreateFunc = nil
new.AfterCreateFunc = nil
new.BeforeUpdateFunc = nil
new.AfterUpdateFunc = nil
new.BeforeDeleteFunc = nil
new.AfterDeleteFunc = nil
clone.BeforeCreateFunc = nil
clone.AfterCreateFunc = nil
clone.BeforeUpdateFunc = nil
clone.AfterUpdateFunc = nil
clone.BeforeDeleteFunc = nil
clone.AfterDeleteFunc = nil

return new
return clone
}

// ModelQuery creates a new preconfigured select query with preset
Expand Down
10 changes: 5 additions & 5 deletions daos/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ func (dao *Dao) DeleteCollection(collection *models.Collection) error {
// SaveCollection persists the provided Collection model and updates
// its related records table schema.
//
// If collecction.IsNew() is true, the method will perform a create, otherwise an update.
// To explicitly mark a collection for update you can use collecction.MarkAsNotNew().
// If collection.IsNew() is true, the method will perform a create, otherwise an update.
// To explicitly mark a collection for update you can use collection.MarkAsNotNew().
func (dao *Dao) SaveCollection(collection *models.Collection) error {
var oldCollection *models.Collection

Expand Down Expand Up @@ -263,11 +263,11 @@ func (dao *Dao) ImportCollections(

// extend existing schema
if !deleteMissing {
schema, _ := existing.Schema.Clone()
schemaClone, _ := existing.Schema.Clone()
for _, f := range imported.Schema.Fields() {
schema.AddField(f) // add or replace
schemaClone.AddField(f) // add or replace
}
imported.Schema = *schema
imported.Schema = *schemaClone
}
} else {
imported.MarkAsNew()
Expand Down
2 changes: 1 addition & 1 deletion forms/record_password_reset_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (form *RecordPasswordResetRequest) SetDao(dao *daos.Dao) {

// Validate makes the form validatable by implementing [validation.Validatable] interface.
//
// This method doesn't checks whether auth record with `form.Email` exists (this is done on Submit).
// This method doesn't check whether auth record with `form.Email` exists (this is done on Submit).
func (form *RecordPasswordResetRequest) Validate() error {
return validation.ValidateStruct(form,
validation.Field(
Expand Down
2 changes: 1 addition & 1 deletion forms/validators/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/pocketbase/pocketbase/daos"
)

// Compare checks whether the provided model id exists.
// UniqueId checks whether the provided model id already exists.
//
// Example:
//
Expand Down
2 changes: 1 addition & 1 deletion mails/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func SendRecordVerification(app core.App, authRecord *models.Record) error {
})
}

// SendUserChangeEmail sends a change email confirmation email to the specified user.
// SendRecordChangeEmail sends a change email confirmation email to the specified user.
func SendRecordChangeEmail(app core.App, record *models.Record, newEmail string) error {
token, tokenErr := tokens.NewRecordChangeEmailToken(app, record, newEmail)
if tokenErr != nil {
Expand Down
Loading

0 comments on commit aabe820

Please sign in to comment.