[https://www.loom.com/share/6bfab4e1dd2445dfbd0004dda08dd8dc](https://www.loom.com/share/6bfab4e1dd2445dfbd0004dda08dd8dc "smartCard-embed")
I think tying the session to origin makes the most sense as you already did, but we should use the spaceId and look up the spaceConfig to figure out whether that space is good for everyone or just that space. As it is each space is a separate origin and only works in its own space.
- Remove origin from Notifications table
- look it up as you are in req.headers.origin, but lookup the spaceConfig to figure out the next action
- if spaceSpecfic then only send to that space
- if not then fire to all sessions
- Remove socketId from emitNotifications as it is no longer used
- Remove origin from session. Replace with spaceId
- This will allow us to change domains for spaces later
- Also allows us to see how many sessions are in each space
- Consolidate notifications logic to emitNotificationCount
- Put the notifcation.create in here
- Run the logic to determine where ntoifcaiton goes to