Skip to content

Commit

Permalink
Orion notifications final (Joystream#264)
Browse files Browse the repository at this point in the history
* User accounts notifications (Joystream#164)

* feat: squash all commits for notification demo

fix: add notification and template choice

feat: sketch mutation for setting the prefeences

fix: arguments for preference selection function

feat: add runtime notification data and notification preferences

fix: notification for runtime events

fix: add notification preference mutation

feat: add email strategy

fix: split Notification into onchain and offchain

fix: add channel created event notifiation

feat: distinguisher between member and channel notifiation

feat: enable offchain notification entities export

fix: notification preferences resolver

fix: migration

feat: default notification preferences

feat: start adding tests

fix: tests

fix: tests

fix: notificatino preference mutation and complete test

fix: add support for offchain dat

fix: missc

fix: format & fix build errors

fix: build and migrations

fix: bugs in setting notifications

fix: add case for notification mutation status

fix: build errors

fix: format

fix: data

* fix: remove non needed entity for migration

export / import scripts allows to specify fields of entities which will be migrated
In this case runtime notification will be migrated partially by offchain and partiall
by handlers

* feat: mark notifications as read

* fix: runtime notification migration generation

* feat: add event notification for video posted

* feat: add video comment

* feat: add chanel verification mutation

* feat: video excluded from app notifications

* feat: channel exclusion

* fix: Channel exclusion

* feat: notification deposit for video reaction

* feat: reaction for comment notification

* feat: refactor and add channel excluded mail template

* fix: email

* feat: regenerate migrations

fix: notifications

fix: misc

* fix: WS_SOURCE for archive

* feat: boilerplate code for notification testing

fix: gql subscriptions

* ♻️ Refactor into object mother like context

* 🩹 Fix: graphql client now working

* 🐛 Logged in client able to send mutation

* ✏️ Fix: set missing notification preferences

* 🩹 Match notification pref names with design

* 🩹 Match notification pref names with design

* 🩹 Fix: SetAccountNotificationPreference resolver

* ✅ Test: Channel created notification

* ✅ Test: FolloChannel notificatino

* ♻️ Ref: notification deposit function

* ✅ Test: Video posted

* ♻️ Ref: addNotification and notification type

* feat: 🎨 create extrinsic file and add make payment to channel

* feat: 🎨 add extra extrinsic for auction notifications

* feat: 🎨 add react to video, comment to video and send payment to channel extrinsics

* refactor: ✨ refactoring code in order to account for manual tests and nft issuance tx status

* feat: 🎨 improve test by adding start auction and start offer

* docs: 📝 review auction bid notification cases and added comments

* fix: 🐛 notify creator on video comment

* fix: 💚 build error

* feat: 🎨 add notification for featured video / nft

* fix: 🐛 channel follower user id

* fix: 🐛 review notification pref parsing

* feat: 🎨 migrate Account to Account with pref (all enabled)

* feat: 🎨 migration from Channel to Channel with verification

* feat: 🎨 offchain notifcations creation timestmap

* refactor: ♻️ Notification code rework to accomodate design specs

* fix: 🎨 notification delivery and fields

* feat: 🎨 no separate notifications

* migration order

* email function rework

* notifications rework

* refactor: ♻️ unify notifications

* fix: 💚 fix notification build error after schema changes

* feat: 🚚 rename and re org utils/notification directory

* fix: 💚 mappings/content/channels tsc errors

* refactor: 💚 fix content/comments and reactions / videos

* fix: 💚 fix content / nft notification deposit

* fix: 💚 channel / resolvers notification deposit

* fix: 💚 Video resolver notification deposit

* fix: 💚 admin resolvers

* fix: 💚 fix direct member payment notification deposit

* fix: 💚 fix notification resolvers

* feat: 🎨 add app root domain

* feat: 🎨 add notification links

* feat: 🎨 notification links

* feat: 🎨 set resolver for setting app_root_domain and notification center

* feat: 🎨 add email content with some formatting

* feat: 🎨 add verify channel resolver with approporiate ChannelVerification entity

* fix: 🔥 no events or notifications are removed

no events or notifications will be removed, since they are now tied to an account and at the mement we don't support account deletion

* feat: 🎨 add royalty payment

* fix: 💚 build errors

* fix: 🩹 patch squid middleware to return 401 for unauth

* fix: 💚 fix ci build

* feat: 🎨 migrate next entity id for account

* temporarely hide integration tests

* fix gitignore

* fix: 💚 eslint fixes

* prettier

* chore: 💚 generate migration data and bump versions

* feat: add channel verification to hidden entities

* feat: 🐛 migrations

* fix: 💚 CI checks on migrations

* notifications visible to accounts

* feat: 🔥 re-establish old visibility policy for notificatinos

* fix: misc

* fix: 🐛 misc fixes for migrations

* feat: 🎨 rename auctionExpired -> timedAuctionExpired and add notificatino for channel suspended

* feat: 🎨 channel suspension resolver

* feat: ✨ better emails

* fix: 🐛 royalty computation and notification id tag

* feat: 🎨 add notification timestamp

* fix: 🐛 purchased nft / channel payment / funds withdrawn notification text

* fix: 🐛 resolvers

* fix: 🐛 VideoHero and channel suspension resolvers

* feat: 💚 fix ci build

* fix: 💚 generate Data.js and add suspension to hidden entities

* fix: 🎨 add channel_suspended to migrated entities

* style: 💄 better name for computeRoyalty args

* fix: 💚 post rebase fixes

* fix: 💚 post rebase fixes

* fix: 💚 post rebase fixes

* Update src/mappings/content/nft.ts

Co-authored-by: attemka <attemka@gmail.com>

* Update src/mappings/content/nft.ts

Co-authored-by: attemka <attemka@gmail.com>

* Update schema/hidden.graphql

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

* Update schema/hidden.graphql

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

* Update schema/hidden.graphql

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

* Update schema/hidden.graphql

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

* Update src/mappings/content/channel.ts

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

* Update src/mappings/content/channel.ts

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

* Update src/server-extension/resolvers/NotificationResolver/index.ts

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

* Update package.json

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

* Update src/server-extension/resolvers/VideosResolver/index.ts

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

* Update src/server-extension/resolvers/ChannelsResolver/index.ts

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

* Update schema/hidden.graphql

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

* fix: 🐛 notification created only once when orion_db is active

* fix: 🎨 misc PR comment address

added non-visibility of notification_delivery_* entities

* feat: 🎨 exported state entity migrated

* fix: 🎨 remove joystream patched types

* fix: 🎨 add ypp status to better match the YTS code

* style: 💄 refactor code for page links

* fix: 🎨 setup text for notifications & regenerate schema

* fix: 🐛 PR comments

feat: ♻️ refactor mail code

fix: ⚡ royalty price precision

fix: 🐛 PR comments

perf: ⚡ add max number of concurrent promises for fetching channel followers

fix: 🐛 PR comments

fix: 🐛 PR comments

fix: 🐛 PR comments

regenerate data

Update src/mappings/content/channel.ts

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

Update src/server-extension/resolvers/VideosResolver/index.ts

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

fix: 🐛 overlay vs orion_db for notification

Now notification are first written in the overlay (if deposited by processor) otherwise they are written directly into orion_db

fix: 🐛 overlay vs orion_db for notification

Now notification are first written in the overlay (if deposited by processor) otherwise they are written directly into orion_db

fix: 🐛 overlay vs orion_db for notification

Now notification are first written in the overlay (if deposited by processor) otherwise they are written directly into orion_db

fix: 🐛 separate mail sent by processor and those sent by server due to overlay presence

fix: 🐛 notification & notification on chain delivery mail deposit

fix: 🐛 notification & notification on chain delivery mail deposit

fix: 🐛 notification & notification on chain delivery mail deposit

* fix: 🐛 rework channel notification data

edit notifications link and text after rework Joystream#2

review addNotifications and start fixing channel

comments and Reaction fixes

fix metadata

fix video mappings

fix utils

fix: nft mappings

fix: admin resolvers

fix: video resolvers

fix channel resolvers

* fix: 🐛 rework channel notification data

edit notifications link and text after rework Joystream#2

review addNotifications and start fixing channel

comments and Reaction fixes

fix metadata

fix video mappings

fix utils

fix: nft mappings

fix: admin resolvers

fix: video resolvers

fix channel resolvers

* fix: 🐛 rework notification data

edit notifications link and text after rework Joystream#2

review addNotifications and start fixing channel

comments and Reaction fixes

fix metadata

fix video mappings

fix utils

fix: nft mappings

fix: admin resolvers

fix: video resolvers

fix channel resolvers

* fix: 🐛 rework notification data

edit notifications link and text after rework Joystream#2

review addNotifications and start fixing channel

comments and Reaction fixes

fix metadata

fix video mappings

fix utils

fix: nft mappings

fix: admin resolvers

fix: video resolvers

fix channel resolvers

* fix: 🐛 rework notification data

edit notifications link and text after rework Joystream#2

review addNotifications and start fixing channel

comments and Reaction fixes

fix metadata

fix video mappings

fix utils

fix: nft mappings

fix: admin resolvers

fix: video resolvers

fix channel resolvers

* fix: 🐛 rework notification data

edit notifications link and text after rework Joystream#2

review addNotifications and start fixing channel

comments and Reaction fixes

fix metadata

fix video mappings

fix utils

fix: nft mappings

fix: admin resolvers

fix: video resolvers

fix channel resolvers

* fix: 🐛 rework notification data

edit notifications link and text after rework Joystream#2

review addNotifications and start fixing channel

comments and Reaction fixes

fix metadata

fix video mappings

fix utils

fix: nft mappings

fix: admin resolvers

fix: video resolvers

fix channel resolvers

---------

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

* fix: uninitialized access of NftPurchased type (Joystream#179)

* Orion notifications fixes (Joystream#195)

* Update squid.yaml

fix: squid.yml version numbering

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

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

* atlas homepage query speed optimisation (Joystream#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 (Joystream#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 (Joystream#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 (Joystream#188)

* style: 🎨 schema & helpers refactor

feat: ✨ resolver for in app notification

* Update the recipient schema

* feat(notification v1): ✨ resolver for in-app notifications

* fix: 🎨 remove inApp delivery entity and inApp resolver no longer used

* fix: 🎨 make notification public and fix linter

* fix: 🐛 PR iter

* test: ✅ test setup missing notificationsj

* test: ✅ add test for set Featured nft

* fix: 🐛 misc fixes after testing

* added referrerChannelId to the Account entity

* fix: ✅ add all tests for missing notifications

* fix: ✅ add all tests for missing notifications

* ci: 💚 add a notifications tests

* fix: 🚨 linter fixes

* fix: 💚 regenerate typeorm-migration scripts

* fix: ✅ update bid related tests and clean test reports

* feat: 🎨 make channel excluded member notification

* feat: 🎨 make channel excluded member notification

* fix: ✨ add event data for channel

* style: 💄 remove unused variant

* fix: ✏️ re check all relation between notification preferences and entities

* fix: ✏️ re check all relation between notification preferences and entities

* fix: ✨ NotificationPreferences Object type for the graphql resolver

* fix: 🐛 distinguish between auction types

* fix: 🐛 distinguish between auction types

---------

Co-authored-by: Zeeshan Akram <37098720+zeeshanakram3@users.noreply.github.com>
Co-authored-by: WRadoslaw <92513933+WRadoslaw@users.noreply.github.com>
Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.com>
Co-authored-by: attemka <attemka@gmail.com>

* fix: 🐛 Video Liked data unitialized (Joystream#204)

* Orion notifications video liked (Joystream#205)

* fix: 🐛 Video Liked data unitialized

* fix: 🐛 Video Liked data unitialized

* test: ✅ add test for video liked

* test: ✅ add test for video liked

* fix: comment id not added to notification data (Joystream#206)

* fix: 🐛 uninitialized notification data fields (Joystream#207)

* migrations to 3.1.0 with fix for Overlay data race during migration (Joystream#200)

* feat: 🎨 add migration for accounts and channels

* test: ✅ add network test folder

* feat: ✅ add archive dump and export to test migrations

* feat: 🐛 overlay and migration data race

* ci: 💚 add ci checks for migration

* fix: ⚰️ remove dead code

* Mail scheduler feature (Joystream#208)

* feat: ✨ start scheduler work

* test: ✅ add test setup

* feat: 🎨 review data model

* feat: 🎨 setup tests and refactor data model

* test: 🎨 add extra seed data

* feat: 🎨 EmailDelivey.status success status changed on sendNew

* feat: 🎨 report entities generated on sendNew

* feat: 🎨 add support for error status

* fix: 🐛 avoid rewriting failedDlivery field on EmailDelivery with old version

* fix: 🎨 add fk for inApp and email delivery no notification entity

* feat: 🎨 add max attempt config variable

* feat: 🎨 seed data for config variable

* fix: 🎨 refactor after rebase

* feat: ✅ start adding test boilerplate code

feat: 🎨 finalize delivery feature

feat: 💚 add ci checks with scheduler tests

fix: 🚨 fix linter

* feat: ⏪ rebase to orion_notifications

* Add an MJML template for email notifications

* Update the links

* Adjust the template after testing it

* Update email links, texts, and icons

* Add avatars in email notifications

* Format amounts of JOYs in the notifications

* Have notification nft links open the nft widget

* Point icon links to GH for now

* Fix the `formatJOY` function

* Add the missing email data

* Update the template for png icons

* Improve avatar code

* Remove unnecessary change

* feat: 🎨 config variables for email

* feat: ✨ add resolvers for setting variables

tested ✅

* feat: enable mail content and remove unused file

* fix: ✅ content delegated to Q&A

* fix: 📦 update package lock

---------

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

* Notifications/scheduler main (Joystream#210)

* feat: ✨ add main function invocation

* feat: ✨ make dbgen

* fix: 🎨 process env not being read for db connection (Joystream#212)

* 👥 Add member ids to `NotificationType` (Joystream#219)

* Add memberIds to some `NotificationType`

* Link to members by ids on emails

* Get member avatars by id on emails

* update notification branch with master (Joystream#220)

* Update squid.yaml

fix: squid.yml version numbering

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

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

* atlas homepage query speed optimisation (Joystream#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 (Joystream#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 (Joystream#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 (Joystream#188)

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

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

* fix: 🎨 process env not being read for db connection

* test: 🧪 add test for email delivery entity deposit

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

* fix: 🐛 encoding issues with member handle

* fix: 🐛 pr issues

* fix: 🐛 refactor and update changelog

* docs: update version number

* fix: 🚑 account counter (Joystream#215)

* fix: 🧪 failing test on migratinos

---------

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

* update with master (Joystream#233)

* Update squid.yaml

fix: squid.yml version numbering

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

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

* atlas homepage query speed optimisation (Joystream#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 (Joystream#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 (Joystream#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 (Joystream#188)

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

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

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

* fix: 🐛 encoding issues with member handle

* fix: 🐛 pr issues

* fix: 🐛 refactor and update changelog

* docs: update version number

* fix: 🚑 account counter (Joystream#215)

* Orion v3.0.3 (Joystream#224)

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

* Remove n+1 problem for StorageDataObject

* Inform user about incorrect query

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

* Orion 303 final touches (Joystream#223)

* feat: ✨ add CORS origins for atlas local testing

* chore: 📝 adds 303 release notes

* Fix typos (Joystream#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 (Joystream#230)

* 🧮 Aggregate channel payments (Joystream#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 (Joystream#228)

---------

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

---------

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>

* 🔨 Fix the notification template (Joystream#234)

* Fix notification template

* Remove `!` from the email subject

* Fix asset links

* Notification branch fixes for issued arised during Q&A (Joystream#225)

* Update squid.yaml

fix: squid.yml version numbering

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

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

* atlas homepage query speed optimisation (Joystream#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 (Joystream#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 (Joystream#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 (Joystream#188)

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

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

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

* fix: 🐛 encoding issues with member handle

* fix: 🐛 pr issues

* fix: 🐛 refactor and update changelog

* docs: update version number

* fix: 🚑 account counter (Joystream#215)

* Orion v3.0.3 (Joystream#224)

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

* Remove n+1 problem for StorageDataObject

* Inform user about incorrect query

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

* Orion 303 final touches (Joystream#223)

* feat: ✨ add CORS origins for atlas local testing

* chore: 📝 adds 303 release notes

* Fix typos (Joystream#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>

* fix(notifications): uninitialized access fields

* fix(notifications): 🐛 add channelId to new auction

* Orion v3.0.4 - Release (Joystream#230)

* 🧮 Aggregate channel payments (Joystream#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 (Joystream#228)

---------

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

* Orion v3.1.0 (Joystream#238)

* Add granular permissions support for Gateway operator users (Joystream#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 (Joystream#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 (Joystream#235)

* add index in video.createdAt field

* add pg_stat_extenstion extenstion for queries stats

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

---------

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

* Hotfix/3.1.0 (Joystream#240)

* Orion v3.1.0 (Joystream#238)

* Add granular permissions support for Gateway operator users (Joystream#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 (Joystream#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 (Joystream#235)

* add index in video.createdAt field

* add pg_stat_extenstion extenstion for queries stats

* docs: ✨ changelog and fix data-js (Joystream#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>

* fix: ✅ add test for comment reply and metadata

* fix: ✨ solve conflicts

* test: ✅ add test for channel verification + refactoring

* chore: 🚨 linter

* fix: 💚 add 10 seconds sleep time for CI checks

* fix: 🐛 channel excluded title

* docs: 📝 typo

---------

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>

* 🩹 Fix JOY values in emails and footer (Joystream#241)

* Fix JOY values in emails

* Fix email footer

* Test `formatJOY` function

* Use `Number.toFixed` to rewrite `formatJOY`

* Fix demo emails

* 🔧 One more notification email fix (Joystream#254)

* Attempt to fix channel avatar on emails

* Improve email template

* Notifications/qa fixes (Joystream#250)

* fix: 🐛 unitialized access video posted + misc

* feat: ⚡ batch channel verification

* fix: ⚡ remove non necessary import

* Notifications/qa fixes (Joystream#255)

* fix: 🐛 unitialized access video posted + misc

* feat: ⚡ batch channel verification

* fix: ⚡ remove non necessary import

* feat: ✨ batch suspend channel and pLimits promises

* Notifications/qa fixes (Joystream#256)

* fix: 🐛 unitialized access video posted + misc

* feat: ⚡ batch channel verification

* fix: ⚡ remove non necessary import

* feat: ✨ batch suspend channel and pLimits promises

* fix: 🐛 typegraphql return type

* Notifications/qa fixes (Joystream#255)

* fix: 🐛 unitialized access video posted + misc

* feat: ⚡ batch channel verification

* fix: ⚡ remove non necessary import

* feat: ✨ batch suspend channel and pLimits promises

* fix: 🎨 import

* style: 💄 format

* Notifications/no self notifications (Joystream#258)

* Update squid.yaml

fix: squid.yml version numbering

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

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

* atlas homepage query speed optimisation (Joystream#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 (Joystream#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 (Joystream#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 (Joystream#188)

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

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

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

* fix: 🐛 encoding issues with member handle

* fix: 🐛 pr issues

* fix: 🐛 refactor and update changelog

* docs: update version number

* fix: 🚑 account counter (Joystream#215)

* Orion v3.0.3 (Joystream#224)

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

* Remove n+1 problem for StorageDataObject

* Inform user about incorrect query

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

* Orion 303 final touches (Joystream#223)

* feat: ✨ add CORS origins for atlas local testing

* chore: 📝 adds 303 release notes

* Fix typos (Joystream#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 (Joystream#230)

* 🧮 Aggregate channel payments (Joystream#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 (Joystream#228)

---------

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

* Orion v3.1.0 (Joystream#238)

* Add granular permissions support for Gateway operator users (Joystream#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 (Joystream#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 (Joystream#235)

* add index in video.createdAt field

* add pg_stat_extenstion extenstion for queries stats

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

---------

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

* Hotfix/3.1.0 (Joystream#240)

* Orion v3.1.0 (Joystream#238)

* Add granular permissions support for Gateway operator users (Joystream#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 (Joystream#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 (Joystream#235)

* add index in video.createdAt field

* add pg_stat_extenstion extenstion for queries stats

* docs: ✨ changelog and fix data-js (Joystream#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>

* 🤞 Fix the channel avatar url (Joystream#257)

* Extract the asset url logic

* Fix the channel avatar url

* Add a script to run the mail scheduler

* fix: 💚 ci error on globalem

* Memoize `getNotificationAvatar`

---------

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

* docs: 📝 changelog (Joystream#260)

* Cache avatars based on just type and id (Joystream#259)

---------

Co-authored-by: attemka <attemka@gmail.com>
Co-authored-by: Zeeshan Akram <37098720+zeeshanakram3@users.noreply.github.com>
Co-authored-by: WRadoslaw <92513933+WRadoslaw@users.noreply.github.com>
Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.com>
Co-authored-by: omahs <73983677+omahs@users.noreply.github.com>
  • Loading branch information
6 people authored Nov 29, 2023
1 parent a5399ad commit 8ac6946
Show file tree
Hide file tree
Showing 94 changed files with 40,197 additions and 15,216 deletions.
11 changes: 11 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ EMAIL_CONFIRMATION_TOKEN_RATE_LIMIT=5
ACCOUNT_OWNERSHIP_PROOF_EXPIRY_TIME_SECONDS=300 # 5 minutes
COOKIE_SECRET=this-is-not-so-secret-change-it

# Notification related variables
APP_ROOT_DOMAIN=gleev.xyz

TRUST_PROXY=uniquelocal

# Sendgrid API
Expand All @@ -61,3 +64,11 @@ SENDGRID_FROM_EMAIL=gateway@example.com
# Debug settings
SQD_DEBUG=api:*
OPENAPI_PLAYGROUND=true

# max number of attempts to deliver email notification
EMAIL_NOTIFICATION_DELIVERY_MAX_ATTEMPTS=5

# Notification emails storage links
APP_ASSET_STORAGE=https://raw.githubusercontent.com/Joystream/atlas-notification-assets/main/logos/gleev
APP_NAME_ALT=Gleev.xyz
NOTIFICATION_ASSET_ROOT=https://raw.githubusercontent.com/Joystream/atlas-notification-assets/main/icons
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
'standard',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:chai-friendly/recommended',
'plugin:prettier/recommended',
'prettier',
],
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,31 @@ name: Tests
on: [push, pull_request]

jobs:
migrations:
name: Run migrations
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Create joystream_default network
run: docker network create joystream_default
- name: Prepare workspace
run: make prepare
- name: Start db
run: docker-compose up -d orion_db
- name: Wait for db
run: |
while ! docker-compose exec -T orion_db pg_isready -U postgres -p 23798; do
sleep 1
done
- name: Run migrations
run: make migrate
auth-api:
name: Auth API tests
needs: [migrations]
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -20,3 +43,62 @@ jobs:
run: make prepare
- name: Run tests
run: npm run tests:auth-api
notifications:
name: orion_db<->service tests for Q&A failing notifications
needs: [migrations]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
fail-fast: true
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{matrix.node-version}}
uses: actions/setup-node@v1
with:
node-version: ${{matrix.node-version}}
- name: Prepare workspace
run: make prepare
- name: Run tests
run: npm run tests:notifications
- name: Run utils tests
run: npm run tests:notifications-utils
mail-scheduler:
name: Mail scheduler tests
needs: [migrations]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
fail-fast: true
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{matrix.node-version}}
uses: actions/setup-node@v1
with:
node-version: ${{matrix.node-version}}
- name: Prepare workspace
run: make prepare
- name: Run tests
run: npm run tests:mail-scheduler
post-update-migrations:
name: Post update migrations tests
needs: [migrations]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
fail-fast: true
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{matrix.node-version}}
uses: actions/setup-node@v1
with:
node-version: ${{matrix.node-version}}
- name: Prepare workspace
run: make prepare
- name: Run tests
run: npm run tests:migrations
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
/**Versions.jsonl

# IDE files
/.vscode
/.idea
src/model/generated
src/auth-server/emails/templates/*.mst
src/auth-server/emails/templates/preview
/schema.graphql
/db/persisted
/scripts/orion-v1-migration/data
/db/export
/db/export
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "lint",
"problemMatcher": [],
"label": "npm: lint",
"detail": "eslint --ext .ts ./src",
"group": {
"kind": "test",
"isDefault": true
}
}
]
}
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
# 3.2.0
This release adds notifications to the orion infrastructure...
## Schema changes
- Introduced `NotificationEmailDelivery` entity to handle email notifications. It includes fields for tracking the notification, delivery attempts, and a discard flag.
- Added `EmailDeliveryAttempt` entity to track each delivery attempt. It includes a status and timestamp.
- Created `DeliveryStatus` union type that can be either `EmailSuccess` or `EmailFailure` (which includes an error status).
- Introduced `Read` and `Unread` types to track if a notification has been read. Both are part of the `ReadOrUnread` union.
- Started defining a `Notification` entity. It includes fields for the account, notification type, event, status, in-app visibility, creation timestamp, and recipient.
- Defined RecipientType as a union of `MemberRecipient` and `ChannelRecipient`.
- Introduced various notification types as part of the NotificationType union. Each type has specific fields relevant to the notification.
- Added `ChannelSuspended, NftFeaturedOnMarketPlace, ChannelVerified, ChannelExcluded, VideoExcluded, NewChannelFollower, CommentPostedToVideo, VideoLiked, VideoDisliked, NftPurchased, CreatorReceivesAuctionBid, NftOffered, DirectChannelPaymentByMember, EnglishAuctionSettled, ChannelFundsWithdrawn, ChannelCreated, CommentReply, ReactionToComment, VideoPosted, NewAuction, NewNftOnSale, HigherBidPlaced, AuctionWon, AuctionLost, BidMadeCompletingAuction, NftRoyaltyPaid` types. Each type includes fields relevant to the specific notification.
- Introduced `AccountNotificationPreferences` type to handle user notification preferences.
- Added fields for each notification type, each of which is of `NotificationPreference` type.
- Channel notifications include: `channelExcludedFromApp, videoExcludedFromApp, nftFeaturedOnMarketPlace, newChannelFollower, videoCommentCreated, videoLiked, videoDisliked, yppChannelVerified, yppSignupSuccessful, yppChannelSuspended, nftBought, creatorTimedAuctionExpired, bidMadeOnNft, royaltyReceived, channelPaymentReceived, channelReceivedFundsFromWg, newPayoutUpdatedByCouncil, channelFundsWithdrawn`.
Member notifications include: `channelCreated, replyToComment, reactionToComment, videoPosted, newNftOnAuction, newNftOnSale, timedAuctionExpired, higherBidThanYoursMade, auctionWon, auctionLost, openAuctionBidCanBeWithdrawn, fundsFromCouncilReceived, fundsToExternalWalletSent, fundsFromWgReceived`.
- Introduced `ChannelYppStatus` as a union type in the GraphQL schema. This type represents the YouTube Partner Program (YPP) status of a channel.
The ChannelYppStatus can be one of three types: `YppUnverified, YppVerified, YppSuspended`.
## Resolvers
- Ypp status mutation resolvers have been introduced, intended for the Ypp verification ops team:
- Added `verifyChannel` mutation is protected by the `OperatorOnly` middleware, meaning it can only be accessed by operators returning a list of `VerifyChannelResults` (each contaning the `id` of the new suspension, the `channelId` of the suspended channel, and the `createdAt` timestamp of when the suspension was created)
- Added `excludeChannel` mutation (protected by the `OperatorOnly` middleware) to the GraphQL schema. This mutation is used to exclude a channel. It takes channelId and rationale as arguments and returns an `ExcludeChannelResult` (contaning the `id` of the new suspension, the `channelId` of the suspended channel, and the `createdAt` timestamp of when the suspension was created)
- Added `suspendChannels` mutation (protected by the `OperatorOnly` middleware) to the GraphQL schema. This mutation is used to suspend. It takes `channelIds` as an argument and returns a list of `SuspendChannelResult` (each contaning the `id` of the new suspension, the `channelId` of the suspended channel, and the `createdAt` timestamp of when the suspension was created)
- Notification-related resolvers (accessible only through the `AccountOnly` middleware) are intened for the use with the front end app:
- Added `markNotificationsAsRead` mutation. This mutation marks specified notifications as read. It takes an array of `notificationIds` and returns an object with an array of IDs of notifications that were successfully marked as read.
- Added `setAccountNotificationPreferences` mutation. This mutation updates the notification preferences for the current account. It takes an object of `newPreferences` and returns the updated notification preferences.
- Both mutations are protected by the `AccountOnly` middleware, meaning they can only be accessed by authenticated accounts.
- Added a helper function `maybeUpdateNotificationPreference` to update individual notification preferences if a new value is provided. This function is used in the `setAccountNotificationPreferences` mutation to update each preference.
- Notification email attepmts and assets
- Added `setMaxAttemptsOnMailDelivery` mutation. This mutation sets the maximum number of attempts to deliver an email notification. It takes `newMaxAttempts` as an argument and returns the new maximum attempts. The mutation is protected by the `OperatorOnly` middleware.
- Introduced `setNewNotificationCenterPath` mutation. This mutation sets the new notification center path. It takes `newMaxAttempts` as an argument and returns the new maximum attempts. The mutation is protected by the `OperatorOnly` middleware.
- Added `setNewAppRootDomain` mutation. This mutation sets the new application root domain. It takes `newRootDomain` as an argument and returns an object indicating whether the new root domain was applied. The mutation is protected by the `OperatorOnly` middleware.
## Mail Scheduler module
- mail template generation using mjml (see `./src/auth-server/emails/templates/mjml/notification.html.mst.mjml`)
- Introduced functions to handle email notifications.
- Added `getMaxAttempts` function to fetch the maximum number of email delivery attempts from the configuration.
- Added `mailsToDeliver` function to fetch all email notifications that have not been discarded.
- Added `deliverEmails` function to process each email notification. It creates the email content, executes the delivery, and records the attempt. If the delivery is successful or the maximum number of attempts has been reached, the notification is discarded.
- The `deliverEmails` function is called in the `main` function, which logs the result of the email delivery process.
- The email delivery is meant (for the moment) to be scheduled via chron job (as explained on operator documentation)
## Misc
- several unit test have been introduced along with CI checks
- Refactored migration logic in order to migrate global account counter, which will be used also to migrate Notifications counters in future releases
## Environment
- Added `EMAIL_NOTIFICATION_DELIVERY_MAX_ATTEMPTS` environment variable to configure the maximum number of attempts to deliver an email notification, before the scheduler stops attending them
- Introduced `APP_ASSET_STORAGE` environment variable to specify the URL where the application's assets are stored.
- Added `APP_NAME_ALT` environment variable to set an alternative name for the application.
- Introduced `NOTIFICATION_ASSET_ROOT` environment variable to specify the URL where the notification icons are stored.
## Documentation
- added documentation for setting up the email scheduler having a [Sendgrid](https://sendgrid.com) account

# 3.1.0

### Entities
Expand Down
4 changes: 2 additions & 2 deletions archive/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DB_PORT=12345
GATEWAY_PORT=8888
WS_SOURCE=wss://rpc.joystream.org:9944
EXPLORER_PORT=4444
WS_SOURCE=ws://joystream-node:9944
EXPLORER_PORT=4444
1 change: 1 addition & 0 deletions archive/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ services:
environment:
DB_TYPE: postgres # set to `cockroach` for Cockroach DB
DB_HOST: archive_db
DB_PORT: '12345'
DB_NAME: 'squid-archive'
DB_USER: 'postgres'
DB_PASS: 'postgres'
Expand Down
20 changes: 20 additions & 0 deletions assets/patches/@subsquid+graphql-server+3.3.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,23 @@ index 04e74c3..e95a07b 100644
};
}
async createTypeormConnection(options) {
diff --git a/node_modules/@subsquid/graphql-server/src/check.ts b/node_modules/@subsquid/graphql-server/src/check.ts
index 51eee8d..683847b 100644
--- a/node_modules/@subsquid/graphql-server/src/check.ts
+++ b/node_modules/@subsquid/graphql-server/src/check.ts
@@ -48,6 +48,15 @@ export function createCheckPlugin(requestCheck: RequestCheckFunction, model: Mod
model
})
if (typeof ok == 'string') {
+ if (ok === 'Unauthorized') {
+ return {
+ errors: [{ message: 'Unauthorized'}],
+ http: {
+ status: 401,
+ headers: new Headers(),
+ },
+ }
+ }
return {errors: [{message: ok}]}
} else if (ok) {
return null
Loading

0 comments on commit 8ac6946

Please sign in to comment.