Callbacks service docs updated
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
mutil "github.com/tech/sendico/pkg/mutil/db"
|
||||
"github.com/tech/sendico/pkg/mutil/mzap"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -54,7 +55,6 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.Any("scope_filter", scopeFilter.BuildQuery()),
|
||||
)
|
||||
|
||||
// 1) Fast path for magic-link tokens: hash is deterministic and globally unique.
|
||||
@@ -69,7 +69,6 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.Any("magic_filter", magicFilter.BuildQuery()),
|
||||
)
|
||||
var direct model.VerificationToken
|
||||
err := db.DBImp.FindOne(ctx, magicFilter, &direct)
|
||||
@@ -152,7 +151,7 @@ func (db *verificationDB) Consume(
|
||||
db.Logger.Debug("Verification consume OTP candidate evaluated",
|
||||
zap.Int("candidate_index", i),
|
||||
zap.Int("candidate_total", len(tokens)),
|
||||
zap.String("candidate_id", t.ID.Hex()),
|
||||
mzap.ObjRef("candidate_ref", t.ID),
|
||||
zap.Bool("candidate_has_salt", t.Salt != nil),
|
||||
zap.Bool("candidate_used", t.UsedAt != nil),
|
||||
zap.Time("candidate_expires_at", t.ExpiresAt),
|
||||
@@ -181,7 +180,6 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.Any("active_filter", activeFilter.BuildQuery()),
|
||||
)
|
||||
|
||||
incremented, patchErr := db.DBImp.PatchMany(
|
||||
@@ -271,8 +269,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
zap.Any("consume_filter", consumeFilter.BuildQuery()),
|
||||
mzap.StorableRef(token),
|
||||
)
|
||||
|
||||
updated, err := db.DBImp.PatchMany(
|
||||
@@ -285,7 +282,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
zap.Error(err),
|
||||
)
|
||||
return nil, err
|
||||
@@ -294,7 +291,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
zap.Int("updated_count", updated),
|
||||
)
|
||||
|
||||
@@ -322,7 +319,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
zap.Error(incrementErr),
|
||||
)
|
||||
} else {
|
||||
@@ -330,7 +327,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
zap.Int("updated_count", incremented),
|
||||
zap.String("transaction_note", "this update occurs inside transaction and may roll back depending on returned error"),
|
||||
)
|
||||
@@ -343,7 +340,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
zap.Error(err),
|
||||
)
|
||||
return nil, merrors.Internal("failed to re-check token state")
|
||||
@@ -353,7 +350,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
}, tokenStateFields(&fresh)...,
|
||||
)...,
|
||||
)
|
||||
@@ -363,7 +360,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
)
|
||||
return nil, verification.ErorrTokenAlreadyUsed()
|
||||
}
|
||||
@@ -372,7 +369,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
zap.Time("now_utc", now),
|
||||
zap.Time("token_expires_at", fresh.ExpiresAt),
|
||||
)
|
||||
@@ -383,7 +380,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
zap.Int("token_attempts", fresh.Attempts),
|
||||
zap.Int("token_max_retries", *fresh.MaxRetries),
|
||||
)
|
||||
@@ -394,7 +391,7 @@ func (db *verificationDB) Consume(
|
||||
zap.String("purpose", string(purpose)),
|
||||
zap.Bool("account_scoped", accountScoped),
|
||||
zap.String("account_ref", accountRefHex),
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
)
|
||||
return nil, verification.ErorrTokenNotFound()
|
||||
},
|
||||
@@ -457,8 +454,8 @@ func tokenIsDigitsOnly(value string) bool {
|
||||
|
||||
func tokenStateFields(token *model.VerificationToken) []zap.Field {
|
||||
fields := []zap.Field{
|
||||
zap.String("token_id", token.ID.Hex()),
|
||||
zap.String("token_account_ref", token.AccountRef.Hex()),
|
||||
mzap.StorableRef(token),
|
||||
mzap.ObjRef("token_account_ref", token.AccountRef),
|
||||
zap.String("token_purpose", string(token.Purpose)),
|
||||
zap.Bool("token_has_target", strings.TrimSpace(token.Target) != ""),
|
||||
zap.Bool("token_has_idempotency_key", token.IdempotencyKey != nil),
|
||||
|
||||
Reference in New Issue
Block a user