Skip to content

Commit

Permalink
fix: 🐛 PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ignazio-bovo committed Aug 22, 2023
1 parent 82dc296 commit d894936
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 44 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"@subsquid/typeorm-migration": "^0.1.4",
"@subsquid/typeorm-store": "^0.2.0",
"@types/lodash": "^4.14.189",
"@types/mjml": "^4.7.1",
"@typescript/analyze-trace": "^0.9.1",
"ajv": "^6.11.0",
"axios": "^1.2.1",
Expand All @@ -61,9 +60,8 @@
"haversine-distance": "^1.2.1",
"lodash": "^4.17.21",
"mjml": "^4.14.1",
"napi-macros": "^2.2.2",
"node-cache": "^5.1.2",
"p-limit": "^4.0.0",
"p-limit": "@3.1.0",
"patch-package": "^6.5.0",
"pg": "8.8.0",
"swagger-ui-express": "^4.6.2",
Expand Down
74 changes: 33 additions & 41 deletions src/server-extension/resolvers/ChannelsResolver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,19 @@ export class ChannelsResolver {
})

const ownerAccount = await getChannelOwnerAccount(em, channel)
if (ownerAccount) {
if (!ctx.account) {
// account not null because of the UseMiddleware(AccountOnly) decorator
throw new Error('Account not specified')
}
const followerAccount = ctx.account
await addNotification(
em,
ownerAccount,
new NewChannelFollower({
recipient: new ChannelRecipient({ channel: channel.id }),
follower: followerAccount.membershipId,
})
)
if (!ctx.account) {
// account not null because of the UseMiddleware(AccountOnly) decorator
throw new Error('Account not specified')
}
const followerAccount = ctx.account
await addNotification(
em,
ownerAccount,
new NewChannelFollower({
recipient: new ChannelRecipient({ channel: channel.id }),
follower: followerAccount.membershipId,
})
)

await em.save([channel, newFollow])

Expand Down Expand Up @@ -369,15 +367,13 @@ export class ChannelsResolver {
const channelOwnerMemberId = channel.ownerMemberId
if (channelOwnerMemberId) {
const account = await em.findOne(Account, { where: { membershipId: channelOwnerMemberId } })
if (account) {
await addNotification(
em,
account,
new ChannelSuspended({
recipient: new ChannelRecipient({ channel: channel.id }),
})
)
}
await addNotification(
em,
account,
new ChannelSuspended({
recipient: new ChannelRecipient({ channel: channel.id }),
})
)
}

return {
Expand Down Expand Up @@ -425,15 +421,13 @@ export class ChannelsResolver {
const channelOwnerMemberId = channel.ownerMemberId
if (channelOwnerMemberId) {
const account = await em.findOne(Account, { where: { membershipId: channelOwnerMemberId } })
if (account) {
await addNotification(
em,
account,
new ChannelVerified({
recipient: new ChannelRecipient({ channel: channel.id }),
})
)
}
await addNotification(
em,
account,
new ChannelVerified({
recipient: new ChannelRecipient({ channel: channel.id }),
})
)
}

return {
Expand Down Expand Up @@ -486,15 +480,13 @@ export class ChannelsResolver {
const channelOwnerMemberId = channel.ownerMemberId
if (channelOwnerMemberId) {
const account = await em.findOne(Account, { where: { membershipId: channelOwnerMemberId } })
if (account) {
await addNotification(
em,
account,
new ChannelExcluded({
recipient: new ChannelRecipient({ channel: channel.id }),
})
)
}
await addNotification(
em,
account,
new ChannelExcluded({
recipient: new ChannelRecipient({ channel: channel.id }),
})
)
}

return {
Expand Down

0 comments on commit d894936

Please sign in to comment.