---
# System prepended metadata

title: Spaces Notification Architecture

---

## Tasks

https://docs.google.com/spreadsheets/d/1JdAOi325rmprT05IBPxTbmuvUFee7LB5cB7WvLC6tSk/edit#gid=0

## Open Questions
- ❗Architecture @todo: Do we distinguish between emails and browser-notifications push notifications?
- ❗Architecture @todo: How do we deal with scheduled emails?
- ❗Disable all comments in this space!
- How do mentions work? Can I decide network-wide? Or per Space.
- what happens, if i don't receive emails for a blog, but want comments on a specific post? 
	- add to ``spaces_notifications_post_blocklist`` (as allowlist)
- what happens if im @mentioned in a post/comment?
	- check if i would receive the post/comment. if not add me to ``spaces_notifications_post_blocklist`` (as allowlist)
- "Always notify me via email of follow-up posts in any topics I reply to"
- UI: Un-/Mute a post.
- Send an email, when a comment is assigned?
- When I'm not a member of a blog: 


## Database architecture [TBUA-23](https://vorhaben.th-koeln.de/browse/TBUA-23)

- All tables are blocklists by default. We should probably loose the `blocklist` suffix, to simplify things (even if all entries are blocklist-entries by default)


```sql

-- Blocklist/allowlist posts for a blog (comments/posts). If a user is a member of a blog she is notified by default
CREATE TABLE `spaces_notifications_blog_blocklist` (
  `blog_id` bigint(20) NOT NULL,
  `user_id` bigint(20) NOT NULL,
  `blocklist_posts` tyniint() NOT NULL, default 1 
  `blocklist_comments` tyniint() NOT NULL, default 1 
  PRIMARY KEY (`blog_id`,`user_id`)
)

-- Blocklist/allowlist comments for a post (when deciding about post-email: only relevant for @mentions)
CREATE TABLE `spaces_notifications_post_blocklist` (
  `blog_id` bigint(20) NOT NULL,
  `post_id` bigint(20) NOT NULL,
  `user_id` bigint(20) NOT NULL,
  `is_allowlist` tyniint() NOT NULL, default 0 
  PRIMARY KEY (`blog_id`,`post_id`,`user_id`)
)

-- Blocklist/allowlist comments & posts for term
CREATE TABLE `spaces_notifications_term_blocklist` (
  `blog_id` bigint(20) NOT NULL,
  `term_id` bigint(20) NOT NULL,
  `user_id` bigint(20) NOT NULL,
  `is_allowlist` tyniint() NOT NULL, default 0 
  PRIMARY KEY (`blog_id`,`post_id`,`user_id`)
)

```

``spaces_notifications_post_blocklist`` (only a allowlist, if a user is not member of the given blog)

- ✅ \#not-any-post-for-blog
- ✅ \#blocklist-post-ids  (comments on post-id)
- ✅ \#subscribe-single-post (when a user is not a member of a space)
- ✅ \#blocklist term-ids
- ~~\#allowlist-taxonomy-ids (when user not memer)~~
- ✨\#blocklist-comments
- ✅\#blocklist-comments-but-one-post
- ✅\#subscribe-single-post
- \#mentioned-in-post

