Skip to content

Commit

Permalink
Notifications/no self notifications (#258)
Browse files Browse the repository at this point in the history
* Update squid.yaml

fix: squid.yml version numbering

* Release PR: Orion v3.0.1 (#185)

* fix: processor's overlay bug (#170)

* atlas homepage query speed optimisation (#177)

* fix: gitignored src/model/generated

* add index on video.video_relevance field

* fix typo in developer guide docs

* regenerate db/migrations/*-Data.js file

* Fix/unblock graphql (#183)

* Make session optional and apply changes for auth handles

* Create new middleware for users and use it on some resolvers

* Remove remaining auth guards

* Small docs change

* Add middleware for channel report

* Prettier

* docs: 📝 update changelog (#184)

---------

Co-authored-by: Zeeshan Akram <37098720+zeeshanakram3@users.noreply.github.com>
Co-authored-by: WRadoslaw <92513933+WRadoslaw@users.noreply.github.com>

* fix: 🚑 fix accountId global counter not being migrated (#188)

* docs: 📝 add back up guide (#196)

* mark 'VideoDeletedByModerator' & 'ChannelDeletedByModerator' events deprecated (#193)

* fix: 🐛 encoding issues with member handle (#214)

* fix: 🐛 encoding issues with member handle

* fix: 🐛 pr issues

* fix: 🐛 refactor and update changelog

* docs: update version number

* fix: 🚑 account counter (#215)

* Orion v3.0.3 (#224)

* Remove n+1 problem for StorageDataObject (#209)

* Remove n+1 problem for StorageDataObject

* Inform user about incorrect query

* fix: ✨ add global counter migratino to account for 303 (#217)

* Orion 303 final touches (#223)

* feat: ✨ add CORS origins for atlas local testing

* chore: 📝 adds 303 release notes

* Fix typos (#176)

* fix typos

* fix typos

* fix typos

* fix typos

* fix typos

* fix typo

* fix typos

* fix typos

* fix typos

* fix typos

* fix typos

* fix typos

---------

Co-authored-by: WRadoslaw <92513933+WRadoslaw@users.noreply.github.com>
Co-authored-by: omahs <73983677+omahs@users.noreply.github.com>

* Orion v3.0.4 - Release (#230)

* 🧮 Aggregate channel payments (#222)

* Fix channels `cumulativeRewardClaimed_DESC` order

* Aggregate channel payments

* Make `cumulativeRewardClaimed` and `cumulativeRewardPaid` non null

* Generate db migrations

* Rename the `cumulativeReward` field

* Re-generate db migrations

* Bump Orion's version

* feat: ⚡ add migration to version 3.0.4 for account id counter (#228)

---------

Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.com>

* Orion v3.1.0 (#238)

* Add granular permissions support for Gateway operator users (#231)

* Add granular permissions support for Gateway operator users

* fix lint issues

* revert docker-compose port change

* mark 'grantPermissions' & 'revokePermissions' input fields are non-nullable & return new permissions instead of boolean

* Set Channel Weight (`setChannelsWeights`) mutation (#232)

* Add granular permissions support for Gateway operator users

* fix lint issues

* add mutation to set channel weight/bias for homepage video relevance

* revert docker-compose port change

* mark 'grantPermissions' & 'revokePermissions' input fields are non-nullable & return new permissions instead of boolean

* bump package version

* update global migration counter map

* bumped package version & updated CHANGELOG

---------

Co-authored-by: Ignazio Bovo <ignazio@jsgenesis.com>

* Postgres performance improvements (#235)

* add index in video.createdAt field

* add pg_stat_extenstion extenstion for queries stats

* docs: ✨ changelog and fix data-js (#237)

---------

Co-authored-by: Zeeshan Akram <37098720+zeeshanakram3@users.noreply.github.com>

* Hotfix/3.1.0 (#240)

* Orion v3.1.0 (#238)

* Add granular permissions support for Gateway operator users (#231)

* Add granular permissions support for Gateway operator users

* fix lint issues

* revert docker-compose port change

* mark 'grantPermissions' & 'revokePermissions' input fields are non-nullable & return new permissions instead of boolean

* Set Channel Weight (`setChannelsWeights`) mutation (#232)

* Add granular permissions support for Gateway operator users

* fix lint issues

* add mutation to set channel weight/bias for homepage video relevance

* revert docker-compose port change

* mark 'grantPermissions' & 'revokePermissions' input fields are non-nullable & return new permissions instead of boolean

* bump package version

* update global migration counter map

* bumped package version & updated CHANGELOG

---------

Co-authored-by: Ignazio Bovo <ignazio@jsgenesis.com>

* Postgres performance improvements (#235)

* add index in video.createdAt field

* add pg_stat_extenstion extenstion for queries stats

* docs: ✨ changelog and fix data-js (#237)

---------

Co-authored-by: Zeeshan Akram <37098720+zeeshanakram3@users.noreply.github.com>

* fix: 🚑 hotfix default value for channel weight no matter what

---------

Co-authored-by: Zeeshan Akram <37098720+zeeshanakram3@users.noreply.github.com>

* docs: 📝 documentation for email notificaions

* feat: 🐛 don't notify channel owner if he's reacting

* feat: 🐛 avoid sending notification for reaction to self comment

* fix: 🎨 pr comments

* fix: 💚 tests faliing on user liking his own video

---------

Co-authored-by: Zeeshan Akram <37098720+zeeshanakram3@users.noreply.github.com>
Co-authored-by: WRadoslaw <92513933+WRadoslaw@users.noreply.github.com>
Co-authored-by: omahs <73983677+omahs@users.noreply.github.com>
Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.com>
  • Loading branch information
5 people committed Nov 29, 2023
1 parent 8ebf19c commit 2e2e2a8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 23 deletions.

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 @@ -365,7 +365,7 @@ describe('notifications tests', () => {
}
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.

0 comments on commit 2e2e2a8

Please sign in to comment.