feat(storage): add native PostgreSQL runtime and verified offline application import
Build and publish container images / images (push) Failing after 12m29s
Build and publish container images / images (push) Failing after 12m29s
This commit is contained in:
1 parent
96065d1e89
commit
0ba1dcfef0
243 files changed
+21441
-3090
No files matched your search
@@ -15,6 +15,9 @@ import (
|
||||
const NotificationPushEventType = ordoschnellic.PushEventType
|
||||
|
||||
func (s *Store) ensureNotificationPushSchema() error {
|
||||
if s.sqlBackend == storePostgreSQL {
|
||||
return s.ensurePostgreSQLPushStorage(context.Background())
|
||||
}
|
||||
_, err := s.DB.Exec(`CREATE TABLE IF NOT EXISTS notification_push_keys(id INTEGER PRIMARY KEY CHECK(id=1),private_key TEXT NOT NULL,public_key TEXT NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS notification_push_subscriptions(
|
||||
id TEXT PRIMARY KEY,domain_uuid TEXT NOT NULL,owner_uuid TEXT NOT NULL,session_hash TEXT NOT NULL,
|
||||
@@ -35,6 +38,9 @@ func (s *Store) ensureNotificationPushSchema() error {
|
||||
}
|
||||
|
||||
func (s *Store) EnsureNotificationPushEvent() error {
|
||||
if !s.SupportsNotificationPush() {
|
||||
return ErrBackendFeatureUnavailable
|
||||
}
|
||||
now := time.Now().UnixMilli()
|
||||
_, err := s.DB.Exec(`INSERT OR IGNORE INTO event_definitions(uuid,name,event_type,event_key,payload,schedule_kind,interval_seconds,next_run_at_ms,enabled,priority,max_attempts,created_at_ms,updated_at_ms) VALUES('builtin.notification.push','Browser notifications',?,'local','{}','interval',30,?,1,-3,3,?,?)`, NotificationPushEventType, now, now, now)
|
||||
return err
|
||||
@@ -42,6 +48,9 @@ func (s *Store) EnsureNotificationPushEvent() error {
|
||||
|
||||
// Never stores the browser's bearer token. Delivery is bound to its revocable session.
|
||||
func (s *Store) SaveNotificationPush(ctx context.Context, domain, owner, token, endpoint, subscription string, focused bool) error {
|
||||
if !s.SupportsNotificationPush() {
|
||||
return ErrBackendFeatureUnavailable
|
||||
}
|
||||
sum := sha256.Sum256([]byte(token))
|
||||
hash := base64.RawURLEncoding.EncodeToString(sum[:])
|
||||
sum = sha256.Sum256([]byte(endpoint))
|
||||
@@ -77,6 +86,9 @@ func (s *Store) SaveNotificationPush(ctx context.Context, domain, owner, token,
|
||||
}
|
||||
|
||||
func (s *Store) DeleteNotificationPush(ctx context.Context, domain, owner, endpoint string) error {
|
||||
if !s.SupportsNotificationPush() {
|
||||
return ErrBackendFeatureUnavailable
|
||||
}
|
||||
sum := sha256.Sum256([]byte(endpoint))
|
||||
id := base64.RawURLEncoding.EncodeToString(sum[:])
|
||||
_, err := s.DB.ExecContext(ctx, `DELETE FROM notification_push_subscriptions WHERE id=? AND domain_uuid=? AND owner_uuid=?`, id, domain, owner)
|
||||
@@ -86,6 +98,9 @@ func (s *Store) DeleteNotificationPush(ctx context.Context, domain, owner, endpo
|
||||
type NotificationPushDelivery = ordoschnellic.PushDelivery
|
||||
|
||||
func (s *Store) AcknowledgeNotificationPush(ctx context.Context, domain, owner, endpoint string, ids []string) error {
|
||||
if !s.SupportsNotificationPush() {
|
||||
return ErrBackendFeatureUnavailable
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -106,6 +121,9 @@ func (s *Store) DeferFocusedNotificationPush(ctx context.Context, d *Notificatio
|
||||
}
|
||||
|
||||
func (s *Store) DeferFocusedNotificationPushAt(ctx context.Context, d *NotificationPushDelivery, at time.Time) error {
|
||||
if !s.SupportsNotificationPush() {
|
||||
return ErrBackendFeatureUnavailable
|
||||
}
|
||||
_, err := s.DB.ExecContext(ctx, `UPDATE notification_push_queue SET attempts=attempts-1,lease_until_ms=0,next_at_ms=? WHERE subscription_id=? AND notification_uuid=? AND attempts=?`, at.Add(ordoschnellic.PushFocusDelay).UnixMilli(), d.ID, d.Notification, d.Attempt)
|
||||
return err
|
||||
}
|
||||
@@ -115,6 +133,9 @@ func (s *Store) ClaimNotificationPush(ctx context.Context) (*NotificationPushDel
|
||||
}
|
||||
|
||||
func (s *Store) ClaimNotificationPushAt(ctx context.Context, at time.Time) (*NotificationPushDelivery, error) {
|
||||
if !s.SupportsNotificationPush() {
|
||||
return nil, ErrBackendFeatureUnavailable
|
||||
}
|
||||
now := at.UnixMilli()
|
||||
tx, err := s.DB.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
@@ -151,6 +172,9 @@ func (s *Store) FinishNotificationPush(ctx context.Context, d *NotificationPushD
|
||||
}
|
||||
|
||||
func (s *Store) FinishNotificationPushAt(ctx context.Context, d *NotificationPushDelivery, retry, expired bool, at time.Time) error {
|
||||
if !s.SupportsNotificationPush() {
|
||||
return ErrBackendFeatureUnavailable
|
||||
}
|
||||
if expired {
|
||||
if _, err := s.DB.ExecContext(ctx, `DELETE FROM notification_push_subscriptions WHERE id=?`, d.ID); err != nil {
|
||||
return err
|
||||
@@ -166,6 +190,9 @@ func (s *Store) FinishNotificationPushAt(ctx context.Context, d *NotificationPus
|
||||
|
||||
// CleanupNotificationPush only removes bounded stale delivery state, not Inbox.
|
||||
func (s *Store) CleanupNotificationPush(ctx context.Context, at time.Time) error {
|
||||
if !s.SupportsNotificationPush() {
|
||||
return ErrBackendFeatureUnavailable
|
||||
}
|
||||
if s.ReadOnly {
|
||||
return ErrReadOnly
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user