Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications/no self notifications #258

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions docs/operator-guide/tutorials/email-notifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Operator email notifications guide

This feature has been introduced in Orion starting from version 3.2.0

The current implementation uses a chron job for executing the
`src/lib/mail-scheduler/index.js` script at every specified interval.
One execution of the above script file will make all the pending email notifications to be send. The plan in the future is to combine all the email for a particular account in a digest form.

## Sendgrid configuration
Configure the `.env` variables with:
- `SENDGRID_API_KEY` : your sendgrid api key
- `SENDGRID_FROM_EMAIL` : your email for which the api key is configured. This email will be used as the sender address for the notifications, we recommend a value like `no-reply@<APPLICATION_ROOT_DOMAIN>` like `no-reply@gleev.xyz` to make it clear to users that it is a service email.


## Notification Email frequency
### Configuring the interval value during orion setup
1. Open up the chrontab file with `crontab -e`
2. Add the following line:
```bash
*/<TIME_INTERVAL_MINUTES> * * * * /home/ubuntu/.volta/bin/node <PATH_TO_ORION_FOLDER>/lib/mail-scheduler/index.js >> <PATH_TO_ORION_FOLDER>/chron_mail_scheduler.log 2>&1
```
replacing the `<PATH_TO_ORION_FOLDER>` with the path to the orion directory cloned for the setup and `<TIME_INTERVAL_MINUTES>` with the desired time interval in minutes. This will make the script to be executed with the desired frequency and it will output the log into a `<PATH_TO_ORION_FOLDER>/chron_mail_scheduler.log` file
3. save and close the crontab file

### Updating the interval value
Same steps as the in the above "Configuring the interval value during orion setup" section
but this time it suffices to update the value for `<TIME_INTERVAL_MINUTES>` and then save the crontab file

### Recommendation for the frequency values
Value ranges from 2 to 5 minutes provides a user experience that is similar to most existing
notification delivery system.
It is important to monitor system usage in case of heavy load and if necessary increase the time interval to a value that doesn't stress excessively your setup
43 changes: 23 additions & 20 deletions src/mappings/content/commentsAndReactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,25 +241,28 @@ async function processVideoReaction(
if (video.channelId) {
const channelOwnerMemberId = await getChannelOwnerMemberByChannelId(overlay, video.channelId)
if (channelOwnerMemberId) {
const memberHandle = await memberHandleById(overlay, memberId)
const channelOwnerAccount = await getAccountForMember(overlay, channelOwnerMemberId)
const reactionData = {
videoId: video.id,
videoTitle: parseVideoTitle(video),
memberId,
memberHandle,
if (channelOwnerMemberId !== memberId) {
// don't notify channel owner if he's the one who reacted
const memberHandle = await memberHandleById(overlay, memberId)
const channelOwnerAccount = await getAccountForMember(overlay, channelOwnerMemberId)
const reactionData = {
videoId: video.id,
videoTitle: parseVideoTitle(video),
memberId,
memberHandle,
}
const reaction =
reactionType === VideoReactionOptions.LIKE
? new VideoLiked(reactionData)
: new VideoDisliked(reactionData)
await addNotification(
overlay,
channelOwnerAccount,
new ChannelRecipient({ channel: video.channelId }),
reaction,
event
)
}
const reaction =
reactionType === VideoReactionOptions.LIKE
? new VideoLiked(reactionData)
: new VideoDisliked(reactionData)
await addNotification(
overlay,
channelOwnerAccount,
new ChannelRecipient({ channel: video.channelId }),
reaction,
event
)
}
}
}
Expand Down Expand Up @@ -392,8 +395,8 @@ export async function processReactCommentMessage(
}),
})

// add notification
if (comment.authorId) {
// add notification if comment author is not the member who reacted
if (memberId !== comment.authorId && comment.authorId) {
const commentAuthorAccount = await getAccountForMember(overlay, comment.authorId)

const notificationData = {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/integration/notifications.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}

const createOverlay = async () => {
return await EntityManagerOverlay.create(new Store(() => globalEm), (_em: EntityManager) =>

Check warning on line 61 in src/tests/integration/notifications.test.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

'_em' is defined but never used
Promise.resolve()
)
}
Expand Down Expand Up @@ -365,7 +365,7 @@
}
const event = {
isV2001: true,
asV2001: ['1', metadataToBytes(MemberRemarked, metadataMessage), undefined],
asV2001: ['3', metadataToBytes(MemberRemarked, metadataMessage), undefined],
} as any
before(async () => {
overlay = await createOverlay()
Expand Down
Binary file added textureAtlas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading