# Notifications 4 Spaces
## Scope
### What will this plugin cover?
There is different things you can think about, when mentioning notifications.
1. Push notifications
2. E-Mail notifications
3. Activity/notifications on website (this might not be important?)
1 & 2 are quite similar. You don't (necessarily) have to aggregate all content for a user (#digests would make this necessary). 3 requires you to do that, so you have to think about a performant way of saving and loading information across multiple blogs.
### Decisions
This is a list of things to think about, and decisions you should take, when you are planning.
- β MVP
- β¨ nice to have
- π½ low prio
#### #digests β
Do we want a daily/weekly digest? In this case we face #challenge-aggregate-performance.
If you generally use (daily) digestes (which is probably a good idea) you loose the option for "instant notifications" ( like: "our meeting will take place an hour later" ). This could be remedied by #overwrite-recipient-preferences.
#### #notify-data
There is lots of things, that could be interesting for a user. The most obvious ones are notifications about:
- β posts
- β comments
There are less obvious ones:
- β¨ send an email about comments with are not approved only to admins (there is a setting in the backend to re). Once it is approved, send to everybody.
- π other post-types (like pages / milestones)
- make sure it is clear, where notifications are sent
- π changes in posts or comments (a post has been updated. not really necessary, you can just write a comment: "updated...")
- does not work for pages... write a post instead
- π changes in the menu (this could be an activity, which is only visible within a blog)
- β¨ @mentions. When a user is mentioned somewhere
- β¨ A conversation in a post you have been part of (even in a space you don't participate)
- this might be solved via subscribing to the post you commented on.
- changes in a blog
- theme change
- user added or removed
- privacy changes (you might have to change the privacy of your posts, when a space becomes visible to the world)
- a blog, where you are a member was archived/deleted.
- an admin edited one of your posts
- things about the user
- β β¨ you were added to a blog (who added you?) - default notification enabled, can be disabled
- β β¨ you were removed from a blog (who?)
- invited to a blog ( <- not a feature yet )
- π platform update
- π blogs, in a blogcategory, that you subscribed ( <- not a feature yet )
- π somebody posted content with a global-hashtag that you subscribe to.
There is probably more things a user could be notified about. It could be worthwhile to look at #general-purpose-activity.
#### #subscription-options
There is several subscription options, you could give a user (this only relates to posts & comments, not other activity-entries).
**Subscribe**
- β All posts (in this blog) - default: active
- β All comments (in this blog) - default: active
- π€·ββοΈπ Single decision: posts & comments?
- catch many things via. delayed/summary notifications?!
- β¨(β ) To comments on a single post?
- β To specific taxonomies (category) - without interface first
- what happens, if a category is assigned to a post after a post has been published
- also think about acitivity
- think about creating & deleting categories
- π To a single post-type
- β¨(β ) To comments on my post?
- β¨To comments on a post im part of the discussion
-
- ...
**Unsubscribe**
- β¨From further comments on this post
- discussion on a post I'm not interested in.
- β From this taxonomy (category)
- π From a post-type ( pages vs. posts )
- π From changes to a post
- ...
**Mixed**
- Not this category, but any new category somebody creates
- All posts, but not comments
- All posts, but not this post
- Only comments, where I'm mentioned
- Only posts, where I'm mentioned
- Conversations, where I'm mentioned
- Unsubscribed to everything. Just notify me, when somebody comments on my post. It's probably better to subscribe to a single post.
- ...
- β mute a user (muted users no longer receive emails)
## More
- Think about private and community posts
- β¨ (Michelle fragt im Expertisezirkel) Slack has some nice "User has notifications turned off" - You still want to notify? **#overwrite-recipient-preferences**
- Platform notification (activity)
- Does this make the world simpler: a category "no notifications"?
- Try to not store things in usermeta, because explosions π£!
- It cound be nice, if a user who writes/creates something knows, who gets notified (before she publishes).
- If external users comment in a public blog, they could also subscribe to new posts/comments.
## Challenges
### #challenge-aggregate-performance
Trying to aggregate content for a user You will quickly recognize some issues
- You need a global table for storing user preferences
- the usermeta is not the right place, as it explodes quickly with a lot of users
## Ideas
### #general-purpose-activity
check: https://wordpress.org/plugins/aryo-activity-log/
As posts and comments are probably not the only things you want your user about idea is about creating activity-objects, which can be used for anything you want to notify users about (buddypress has an activity-table like this?).
- You could have activity-templates, which give their activity a form
- You could have an activity-store, which contains data for all activities with relations about the blog, the user, the category, the post, ...
- You could have a user-activity table, where you have a timestamped affiliation between activities and users.
- When you do a daily digest, you would just have to look at the timestamp and select the newer ones
Pros/Cons:
- π You can timely limit your activity (1year?), so the table is not endlessly filling.
- π The information is quite compact, as you keep templating and data seperated
- π You don't have to save user preferences globally (but can store them in a the blogs, they are related to, in the case of posts and comments). You are "sending" activity to the store, when it is created, and check which users the activity is relevant for. So the whole "permission-checking" privacy
- β Once an activity is in the store (in this case), it stays there, even if the user changes her settings. So settings only apply to future activity-entries.
- β What do we do, if an activity-entry changes (a post is updated or deleted)? It looks like there needs to be a link between activity entries and the data.
- π redundant data
### #concise-option-store
It is quite difficult to store user-preferences in a concise manner.
Take the example for a blog with 100 categories and 100 users
(We assume, that you want to allow users to select categories they want to subscribe to). You get 10k entries. And how do you deal with new categories?
It is probably smart to work with both black- and whitelisting.
One way to approach this is by the following ideas:
- All data is nested (which is not 100% true) check #nested-structures
- We allow blacklisting & whitelisting
- We assume, rules cascade
As CSS does this, here is an example/ thought experiment:
https://codepen.io/mackbird/full/xxObMVm
There is a stackoverflow question here: https://stackoverflow.com/questions/66972181/how-do-i-create-a-database-structure-for-css-like-selectors
Note: Xpath has css-like selectors.
- β A post can be contained in multiple categories. When doing selecting the "CSS-way" a post could exist in multiple nodes. This has to be reduced later (also for comments)
- β How do we store such rules?
- β How do we translate user-input into those rules (I'm quite sure, there is people, who already created software for solving those questions :))
### #nested-structures
Thinking about a blog like:
- blog
- taxonomy-1
- post-1
- comment-1
- comment-2
- post-2
- taxonomy-2
- post-1
- comment-1
- comment-2
- post-3
### #overwrite-recipient-preferences
There are some use-cases, where you don't want to "respect" your recipient's settings:
- don't notify!: don't notify users about an entry you create (post/page).
e.c. you prepare something for your meeting you want to discuss tomorrow.
- notify!: You have a message which needs to reach your users users "now" "urgently".
e.c. "Meeting today will be delayed one hour". (Slack does something like this)
This comes with some challenges:
- You need interfaces to "override" in a simple way.
- You need interfaces which clarify, that the user's preference has been overridden. Otherwise you will get lots of feedback: "I didn't receive an email for this!".
### #undo
Undo sending?
### #retired-users
If a user has not logged in for a year, the account is retired:
- send an email: if you want to get emails you have to log in again.
- then: don't send emaily anymore...
## Resources
https://github.com/johnbillion/wp_mail
###### tags: `KISD` `TH` `Kunden`