From 8535d011d00098e795efbf8f17764480ad362812 Mon Sep 17 00:00:00 2001 From: ae Date: Sun, 4 May 2025 11:24:00 +0300 Subject: [PATCH] docs: util function docstrings --- server/internal/service/util.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/internal/service/util.go b/server/internal/service/util.go index 8ea7258..32060b3 100644 --- a/server/internal/service/util.go +++ b/server/internal/service/util.go @@ -206,6 +206,9 @@ func sha1ContentHash(title, content string) string { return hashStr } +// Parse either an absolute (e.g. '2006-01-02') or a relative expiration date (e.g. '+3d') from +// the beginning of the title prefixed with either '@exp:' or '@expires:'. The actual note +// expiration will be set to the end of that particular date (+0000 UTC). func parseTitleExpiration(title *string) (*time.Time, error) { // Absolute date format: '@exp:YYYY-MM-DD' (or '@expires:') if match := dateFormatRegex.FindStringSubmatch(*title); match != nil { @@ -265,6 +268,7 @@ func parseTitleExpiration(title *string) (*time.Time, error) { return nil, ErrNoExpirationDateFound } +// Ensure a given date (time) is between the current time and current time + `maxFutureExpirationYears`. func validateExpirationDate(date time.Time) error { now := time.Now() @@ -280,6 +284,8 @@ func validateExpirationDate(date time.Time) error { return nil } +// Run a database cleanup task that queries the currently expired notes in the database, prints +// metadata about them, and deletes them. func cleanupNotes(ctx context.Context, q *data.Queries) { expiredNotes, err := q.ListExpiredNotes(ctx) if err != nil { @@ -305,6 +311,7 @@ func cleanupNotes(ctx context.Context, q *data.Queries) { log.Info().Msgf("Successfully deleted %d expired notes during scheduled cleanup", len(expiredNotes)) } +// Run a database cleanup task that deletes the expired and revoked refresh tokens. func cleanupRefreshTokens(ctx context.Context, q *data.Queries) { rowsAffected, err := q.DeleteExpiredRefreshTokens(ctx) if err != nil {