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

Notification branch fixes for issued arised during Q&A #225

Merged
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
5 changes: 3 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ VIDEO_RELEVANCE_VIEWS_TICK=50
# views weight,
# comments weight,
# rections weights,
# [joystream creation weight, YT creation weight]
# [joystream creation weight, YT creation weight],
# Default channel weight/bias
# ]
RELEVANCE_WEIGHTS="[1, 0.03, 0.3, 0.5, [7,3]]"
RELEVANCE_WEIGHTS="[1, 0.03, 0.3, 0.5, [7,3], 1]"
MAX_CACHED_ENTITIES=1000
APP_PRIVATE_KEY=this-is-not-so-secret-change-it
SESSION_EXPIRY_AFTER_INACTIVITY_MINUTES=60
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# 3.1.0
# 3.2.0
This release adds notifications to the orion infrastructure...

# 3.1.0

### Entities
- Adds `User.permission` to the `User` entity, this however doesn't require migration logic.
- Adds `Channel.channelWeights` in order to boost channel relevance. This value can be set via the `setChannelWeights` mutation
### Resolvers
- Adds supports for new permissions model for gateway operator users. Now the root user can assign/revoke operator permission/s to users using `grantPermissions` & `revokePermissions` mutations
- Adds new `setChannelWeights` operator mutation to set weight/bias for any channel/s which will be used to calculate the Atlas homepage video relevance scores
### Performance
- Adds `Video.createdAt` as index in order to speed up Atlas home page queries

# 3.0.4

### Misc
Expand Down

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

4 changes: 4 additions & 0 deletions db/migrations/2200000000000-Operator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ module.exports = class Operator2300000000000 {
INSERT INTO "admin"."user" ("id", "is_root")
VALUES ('${process.env.OPERATOR_SECRET || randomAsHex(32)}', true);
`)

// Create pg_stat_statements extension for analyzing query stats
await db.query(`CREATE EXTENSION pg_stat_statements`)
}

async down(db) {
await db.query(`DELETE FROM "admin"."user" WHERE "is_root" = true;`)
await db.query(`DROP EXTENSION pg_stat_statements`)
}
}
4 changes: 3 additions & 1 deletion db/postgres.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ log_statement = all
autovacuum_analyze_scale_factor = 0.01
shared_buffers=2GB
jit=off
random_page_cost=1.0
random_page_cost=1.0
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ services:
POSTGRES_DB: squid
POSTGRES_PASSWORD: squid
ports:
- '127.0.0.1:${DB_PORT}:${DB_PORT}'
- '[::1]:${DB_PORT}:${DB_PORT}'
- '${DB_PORT}:${DB_PORT}'
command: ['postgres', '-c', 'config_file=/etc/postgresql/postgresql.conf', '-p', '${DB_PORT}']
shm_size: 1g
volumes:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orion",
"version": "3.1.0",
"version": "3.2.0",
"engines": {
"node": ">=16"
},
Expand Down
18 changes: 18 additions & 0 deletions schema/auth.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
enum OperatorPermission {
GRANT_OPERATOR_PERMISSIONS
REVOKE_OPERATOR_PERMISSIONS
SET_VIDEO_WEIGHTS
SET_CHANNEL_WEIGHTS
SET_KILL_SWITCH
SET_VIDEO_VIEW_PER_USER_TIME_LIMIT
SET_VIDEO_HERO
SET_CATEGORY_FEATURED_VIDEOS
SET_SUPPORTED_CATEGORIES
SET_FEATURED_NFTS
EXCLUDE_CONTENT
RESTORE_CONTENT
}

type User @entity {
"Unique identifier (32-byte string, securely random)"
id: ID!

"Whether the user has root (gateway operator) privileges"
isRoot: Boolean!

"List of all the gateway operator permissions that this user has"
permissions: [OperatorPermission!]

"The account associated with the user (if any)"
account: Account @derivedFrom(field: "user")

Expand Down
5 changes: 4 additions & 1 deletion schema/channels.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type Channel @entity {
id: ID!

"Timestamp of the block the channel was created at"
createdAt: DateTime!
createdAt: DateTime! @index

"Current member-owner of the channel (if owned by a member)"
ownerMember: Membership
Expand Down Expand Up @@ -65,6 +65,9 @@ type Channel @entity {
"Cumulative rewards paid to this channel"
cumulativeReward: BigInt!

"Weight/Bias of the channel affecting video relevance in the Homepage"
channelWeight: Float

"Channel Ypp Status: either unverified , verified or suspended"
yppStatus: ChannelYppStatus!
}
Expand Down
4 changes: 3 additions & 1 deletion schema/notifications.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ type NftFeaturedOnMarketPlace @variant {
}

type ChannelVerified @variant {
"no data needed as recipient is channel"
phantom: Int
}

type ChannelExcluded @variant {
phantom: Int
"title for the channel used for notification text"
channelTitle: String!
}

type VideoExcluded @variant {
Expand Down
3 changes: 0 additions & 3 deletions src/mail-scheduler/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { config as dontenvConfig } from 'dotenv'
import path from 'path'

import { ConfigVariable, config } from '../utils/config'
import { EmailDeliveryAttempt, NotificationEmailDelivery } from '../model'
import { EntityManager } from 'typeorm'
Expand Down
4 changes: 3 additions & 1 deletion src/mappings/content/commentsAndReactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,13 @@ export async function processCreateCommentMessage(
videoId: video.id,
videoTitle: parseVideoTitle(video),
memberHandle: await memberHandleById(overlay, memberId),
memberId,
}
const memberRecipientId = parentComment.authorId || undefined
await addNotification(
overlay,
authorAccount,
new MemberRecipient({ membership: comment.authorId }),
new MemberRecipient({ membership: memberRecipientId }),
new CommentReply(notificationData),
event
)
Expand Down
4 changes: 3 additions & 1 deletion src/mappings/content/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import {
NftOfferedEventData,
Account,
MemberRecipient,
AuctionTypeOpen,
} from '../../model'
import { addNftActivity, addNftHistoryEntry, genericEventFields } from '../utils'
import { SubstrateBlock, assertNotNull } from '@subsquid/substrate-processor'
Expand Down Expand Up @@ -91,6 +90,7 @@ export async function processOpenAuctionStartedEvent({
if (video.channelId) {
const channelTitle = await getChannelTitleById(overlay, video.channelId)
const notificationData = new NewAuction({
channelId: video.channelId,
channelTitle,
videoId: video.id,
videoTitle: parseVideoTitle(video),
Expand Down Expand Up @@ -138,6 +138,7 @@ export async function processEnglishAuctionStartedEvent({
if (video.channelId) {
const channelTitle = await getChannelTitleById(overlay, video.channelId)
const notificationData = new NewAuction({
channelId: video.channelId,
channelTitle,
videoId: video.id,
videoTitle: parseVideoTitle(video),
Expand Down Expand Up @@ -547,6 +548,7 @@ export async function processNftSellOrderMadeEvent({
if (video?.channelId) {
const channelTitle = await getChannelTitleById(overlay, video.channelId)
const notificationData = new NewNftOnSale({
channelId: video.channelId,
channelTitle,
videoId: video.id,
videoTitle: parseVideoTitle(video),
Expand Down
7 changes: 5 additions & 2 deletions src/mappings/content/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,11 @@ export function computeRoyalty(royaltyPct: number, price: bigint): bigint {
}

export function parseChannelTitle(channel: Flat<Channel>): string {
return channel.title || '??'
return channel.title || FALLBACK_CHANNEL_TITLE
}

export function parseVideoTitle(video: Flat<Video>): string {
return video.title || '??'
return video.title || FALLBACK_VIDEO_TITLE
}

export async function memberHandleById(
Expand All @@ -886,3 +886,6 @@ export async function getChannelTitleById(overlay: EntityManagerOverlay, channel
const channel = await overlay.getRepository(Channel).getByIdOrFail(channelId)
return parseChannelTitle(channel)
}

export const FALLBACK_CHANNEL_TITLE = '??'
export const FALLBACK_VIDEO_TITLE = '??'
4 changes: 2 additions & 2 deletions src/server-extension/check.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { RequestCheckFunction } from '@subsquid/graphql-server/lib/check'
import { Context as OpenreaderContext } from '@subsquid/openreader/lib/context'
import { TypeormOpenreaderContext } from '@subsquid/graphql-server/lib/typeorm'
import { AuthContext, authenticate } from '../utils/auth'
import { Context as OpenreaderContext } from '@subsquid/openreader/lib/context'
import { UnauthorizedError } from 'type-graphql'
import { AuthContext, authenticate } from '../utils/auth'

export type Context = OpenreaderContext & AuthContext

Expand Down
Loading
Loading