Mobile notifications for iOS (#210)
* mobile: wire notification registration and listener
* implement backend components for push notifications
* refactor: agentic comment cleanup
* docs: use proper module name for particle processor
* set required env variables for push notifications
* bump version
* fix: always upsert push token on mobile start
* Revert "fix: always upsert push token on mobile start"
This reverts commit 90ff18a788.
* send push notifications regardless of online status
This commit was merged in pull request #210.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package network
|
||||
|
||||
import "strings"
|
||||
|
||||
// ResolveVisibility expands a stream particle's visible_to entries into the set
|
||||
// of human IDs that should see (and thus be notified about) activity in that
|
||||
// stream. Entries are formatted as `human:{id}` for a specific human or
|
||||
// `network:{id}` to expand to every member of the surrounding network.
|
||||
//
|
||||
// networkMembers must contain every human currently in the network (members +
|
||||
// admin). visible_to entries that point to humans no longer in the network are
|
||||
// dropped — they may have been removed since the stream was created.
|
||||
//
|
||||
// Returns a deduped slice; ordering is not stable.
|
||||
func ResolveVisibility(visibleTo []string, networkMembers []string) []string {
|
||||
memberSet := make(map[string]bool, len(networkMembers))
|
||||
for _, id := range networkMembers {
|
||||
memberSet[id] = true
|
||||
}
|
||||
|
||||
result := make(map[string]bool)
|
||||
for _, entry := range visibleTo {
|
||||
switch {
|
||||
case strings.HasPrefix(entry, "human:"):
|
||||
id := strings.TrimPrefix(entry, "human:")
|
||||
if memberSet[id] {
|
||||
result[id] = true
|
||||
}
|
||||
case strings.HasPrefix(entry, "network:"):
|
||||
for id := range memberSet {
|
||||
result[id] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out := make([]string, 0, len(result))
|
||||
for id := range result {
|
||||
out = append(out, id)
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user