diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1f1c14f..a695f99 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,10 +4,8 @@ - @@ -178,7 +175,8 @@ - true diff --git a/pkg/internal/services/notifications.go b/pkg/internal/services/notifications.go index bfbd18a..61ad21f 100644 --- a/pkg/internal/services/notifications.go +++ b/pkg/internal/services/notifications.go @@ -2,6 +2,8 @@ package services import ( "context" + "reflect" + "firebase.google.com/go/messaging" "git.solsynth.dev/hydrogen/passport/pkg/internal/database" "git.solsynth.dev/hydrogen/passport/pkg/internal/models" @@ -9,7 +11,6 @@ import ( "github.com/sideshow/apns2" payload2 "github.com/sideshow/apns2/payload" "github.com/spf13/viper" - "reflect" ) func AddNotifySubscriber(user models.Account, provider, id, tk, ua string) (models.NotificationSubscriber, error) { diff --git a/pkg/internal/services/statuses.go b/pkg/internal/services/statuses.go index ba413ab..813ac3a 100644 --- a/pkg/internal/services/statuses.go +++ b/pkg/internal/services/statuses.go @@ -2,10 +2,11 @@ package services import ( "fmt" + "time" + "git.solsynth.dev/hydrogen/passport/pkg/internal/database" "git.solsynth.dev/hydrogen/passport/pkg/internal/models" "github.com/samber/lo" - "time" ) var statusCache = make(map[uint]models.Status) @@ -30,15 +31,17 @@ func GetStatus(uid uint) (models.Status, error) { return status, nil } +func GetUserOnline(uid uint) bool { + return wsConn[uid] != nil && len(wsConn[uid]) > 0 +} + func GetStatusDisturbable(uid uint) error { status, err := GetStatus(uid) - isOnline := wsConn[uid] != nil && len(wsConn[uid]) > 0 + isOnline := GetUserOnline(uid) if isOnline && err != nil { return nil } else if err == nil && status.IsNoDisturb { return fmt.Errorf("do not disturb") - } else if !isOnline { - return fmt.Errorf("offline") } else { return nil } diff --git a/web/bun.lockb b/web/bun.lockb new file mode 100755 index 0000000..29dcf9b Binary files /dev/null and b/web/bun.lockb differ