diff --git a/db/migrations/1688395806930-Data.js b/db/migrations/1688479161138-Data.js similarity index 99% rename from db/migrations/1688395806930-Data.js rename to db/migrations/1688479161138-Data.js index 9358d701a..61f34601f 100644 --- a/db/migrations/1688395806930-Data.js +++ b/db/migrations/1688479161138-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1688395806930 { - name = 'Data1688395806930' +module.exports = class Data1688479161138 { + name = 'Data1688479161138' async up(db) { await db.query(`CREATE TABLE "channel_follow" ("id" character varying NOT NULL, "user_id" character varying, "channel_id" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, CONSTRAINT "PK_9410df2b9a316af3f0d216f9487" PRIMARY KEY ("id"))`) diff --git a/src/auth-server/handlers/createAccount.ts b/src/auth-server/handlers/createAccount.ts index b5c75878c..62deb5896 100644 --- a/src/auth-server/handlers/createAccount.ts +++ b/src/auth-server/handlers/createAccount.ts @@ -78,6 +78,7 @@ export const createAccount: ( } + const notificationPreferences = defaultNotificationPreferences() const account = new Account({ id: idStringFromNumber(nextAccountId), email, @@ -87,8 +88,8 @@ export const createAccount: ( userId: authContext.user.id, joystreamAccount: joystreamAccountId, membershipId: memberId.toString(), + ...notificationPreferences, }) - setNotificationPreferences(account, defaultNotificationPreferences()) await em.save([ account, diff --git a/src/auth-server/integration-tests/utils.sh b/src/auth-server/integration-tests/utils.sh index d0abaaf74..568d10e01 100755 --- a/src/auth-server/integration-tests/utils.sh +++ b/src/auth-server/integration-tests/utils.sh @@ -56,11 +56,12 @@ curl --request POST \ echo "*********************************************************************** " >&2 echo "Preferences update: mutate" >&2 -curl --request POST \ - --url http://localhost:4350/graphql \ +curl -i \ + --request POST \ + --url 'http://localhost:4350/graphql?=' \ --header 'Content-Type: application/json' \ --header "Cookie: session_id=${LOGIN_SESSION_ID}" \ - --data '{"query":"mutation SetNotificationPreferences {\n\tsetAccountNotificatioPreferences(\n\t\tauctionBidCanceledInAppNotificationEnabled: false\n\t\tauctionBidCanceledMailNotificationEnabled: false\n\t\tauctionBidMadeInAppNotificationEnabled: false\n\t\tauctionBidMadeMailNotificationEnabled: false\n\t\tauctionCanceledInAppNotificationEnabled: false\n\t\tauctionCanceledMailNotificationEnabled: false\n\t\tbidMadeCompletingAuctionInAppNotificationEnabled: false\n\t\tbidMadeCompletingAuctionMailNotificationEnabled: false\n\t\tbuyNowCanceledInAppNotificationEnabled: false\n\t\tbuyNowCanceledMailNotificationEnabled: false\n\t\tbuyNowPriceUpdatedInAppNotificationEnabled: false\n\t\tbuyNowPriceUpdatedMailNotificationEnabled: false\n\t\tchannelCreatedInAppNotificationEnabled: false\n\t\tchannelCreatedMailNotificationEnabled: false\n\t\tchannelFundsWithdrawnInAppNotificationEnabled: false\n\t\tchannelFundsWithdrawnMailNotificationEnabled: false\n\t\tchannelPaymentMadeInAppNotificationEnabled: false\n\t\tchannelPaymentMadeMailNotificationEnabled: false\n\t\tchannelPayoutsUpdatedInAppNotificationEnabled: false\n\t\tchannelPayoutsUpdatedMailNotificationEnabled: false\n\t\tchannelRewardClaimedAndWithdrawnInAppNotificationEnabled: false\n\t\tchannelRewardClaimedAndWithdrawnMailNotificationEnabled: false\n\t\tchannelRewardClaimedInAppNotificationEnabled: false\n\t\tchannelRewardClaimedMailNotificationEnabled: false\n\t\tcommentCreatedInAppNotificationEnabled: false\n\t\tcommentCreatedMailNotificationEnabled: false\n\t\tcommentTextUpdatedInAppNotificationEnabled: false\n\t\tcommentTextUpdatedMailNotificationEnabled: false\n\t\tenglishAuctionSettledInAppNotificationEnabled: false\n\t\tenglishAuctionSettledMailNotificationEnabled: false\n\t\tenglishAuctionStartedInAppNotificationEnabled: false\n\t\tenglishAuctionStartedMailNotificationEnabled: false\n\t\tmemberBannedFromChannelInAppNotificationEnabled: false\n\t\tmemberBannedFromChannelMailNotificationEnabled: false\n\t\tmetaprotocolTransactionStatusMailNotificationEnabled: false\n\t\tnftBoughtInAppNotificationEnabled: false\n\t\tnftBoughtMailNotificationEnabled: false\n\t\tnftIssuedInAppNotificationEnabled: false\n\t\tnftIssuedMailNotificationEnabled: false\n\t\tnftSellOrderMadeInAppNotificationEnabled: false\n\t\tnftSellOrderMadeMailNotificationEnabled: false\n\t\topenAuctionBidAcceptedInAppNotificationEnabled: false\n\t\topenAuctionBidAcceptedMailNotificationEnabled: false\n\t\topenAuctionStartedInAppNotificationEnabled: false\n\t\topenAuctionStartedMailNotificationEnabled: false\n\t\tmetaprotocolTransactionStatusInAppNotificationEnabled: false\n\t)\n}\n","operationName":"SetNotificationPreferences"}' + --data '{"query":"mutation SetAccountNotificationPrefences {\n\tsetAccountNotificationPreferences(\n\t\tauctionBidCanceledInAppNotificationEnabled: false\n\t\tauctionBidCanceledMailNotificationEnabled: false\n\t\tauctionBidMadeInAppNotificationEnabled: false\n\t\tauctionBidMadeMailNotificationEnabled: false\n\t\tauctionCanceledInAppNotificationEnabled: false\n\t\tauctionCanceledMailNotificationEnabled: false\n\t\tbidMadeCompletingAuctionInAppNotificationEnabled: false\n\t\tbidMadeCompletingAuctionMailNotificationEnabled: false\n\t\tbuyNowCanceledMailNotificationEnabled: false\n\t\tbuyNowPriceUpdatedInAppNotificationEnabled: false\n\t\tbuyNowPriceUpdatedMailNotificationEnabled: false\n\t\tchannelCreatedInAppNotificationEnabled: false\n\t\tchannelCreatedMailNotificationEnabled: false\n\t\tchannelFundsWithdrawnInAppNotificationEnabled: false\n\t\tchannelFundsWithdrawnMailNotificationEnabled: false\n\t\tchannelPaymentMadeInAppNotificationEnabled: false\n\t\tchannelPaymentMadeMailNotificationEnabled: false\n\t\tchannelPayoutsUpdatedInAppNotificationEnabled: false\n\t\tchannelPayoutsUpdatedMailNotificationEnabled: false\n\t\tchannelRewardClaimedAndWithdrawnInAppNotificationEnabled: false\n\t\tchannelRewardClaimedAndWithdrawnMailNotificationEnabled: false\n\t\tchannelRewardClaimedInAppNotificationEnabled: false\n\t\tchannelRewardClaimedMailNotificationEnabled: false\n\t\tcommentCreatedInAppNotificationEnabled: false\n\t\tcommentCreatedMailNotificationEnabled: false\n\t\tcommentTextUpdatedInAppNotificationEnabled: false\n\t\tcommentTextUpdatedMailNotificationEnabled: false\n\t\tenglishAuctionSettledInAppNotificationEnabled: false\n\t\tenglishAuctionSettledMailNotificationEnabled: false\n\t\tenglishAuctionStartedInAppNotificationEnabled: false\n\t\tenglishAuctionStartedMailNotificationEnabled: false\n\t\tmemberBannedFromChannelInAppNotificationEnabled: false\n\t\tmemberBannedFromChannelMailNotificationEnabled: false\n\t\tmetaprotocolTransactionStatusInAppNotificationEnabled: false\n\t\tmetaprotocolTransactionStatusMailNotificationEnabled: false\n\t\tnewChannelFollowerInAppNotificationPreferences: false\n\t\tnewChannelFollowerMailNotificationPreferences: false\n\t\tnftBoughtInAppNotificationEnabled: false\n\t\tnftBoughtMailNotificationEnabled: false\n\t\tnftIssuedMailNotificationEnabled: false\n\t\tnftSellOrderMadeInAppNotificationEnabled: false\n\t\tnftSellOrderMadeMailNotificationEnabled: false\n\t\topenAuctionBidAcceptedInAppNotificationEnabled: false\n\t\topenAuctionBidAcceptedMailNotificationEnabled: false\n\t\topenAuctionStartedInAppNotificationEnabled: false\n\t\topenAuctionStartedMailNotificationEnabled: false\n\t)\n}\n","operationName":"SetAccountNotificationPrefences"}' echo "*********************************************************************** " >&2 echo "Notification visibility as an anon user" >&2 diff --git a/src/mappings/utils.ts b/src/mappings/utils.ts index 0f7c12efb..b39c3900a 100644 --- a/src/mappings/utils.ts +++ b/src/mappings/utils.ts @@ -110,6 +110,12 @@ export async function addNotificationForRuntimeData( const notificationAlreadyProcessedInThePast = await overlay .getRepository(RuntimeNotificationProcessed) .getOneByRelation('runtimeNotificationId', newNotificationId) + + console.log("account", JSON.stringify(account)) + console.log("notificationId", newNotificationId) + console.log("event", event.id) + console.log("type", JSON.stringify(type)) + repository.new({ id: newNotificationId, accountId: account.id, @@ -118,9 +124,10 @@ export async function addNotificationForRuntimeData( }) if (!notificationAlreadyProcessedInThePast) { const notificationProcessed = overlay.getRepository(RuntimeNotificationProcessed).new({ - id: newNotificationId, + id: overlay.getRepository(RuntimeNotificationProcessed).getNewEntityId(), inAppRead: false, mailSent: false, + runtimeNotificationId: newNotificationId, }) if (shouldSendMail) { mailNotifier.setReciever(account.email) diff --git a/src/server-extension/resolvers/NotificationResolver/index.ts b/src/server-extension/resolvers/NotificationResolver/index.ts index 0fd971f3b..562fa0dfa 100644 --- a/src/server-extension/resolvers/NotificationResolver/index.ts +++ b/src/server-extension/resolvers/NotificationResolver/index.ts @@ -15,7 +15,7 @@ import { NotificationArgs, SetNotificationPreferencesArgs } from './types' @Resolver() export class NotificationResolver { // Set by depenency injection - constructor(private em: () => Promise) {} + constructor(private em: () => Promise) { } @Mutation(() => Boolean) @UseMiddleware(AccountOnly) @@ -124,7 +124,7 @@ export class NotificationResolver { @Mutation(() => Boolean) @UseMiddleware(AccountOnly) - async setAccountNotificatioPreferences( + async setAccountNotificationPreferences( @Args() notificationPreferences: SetNotificationPreferencesArgs, @Ctx() ctx: Context ): Promise { @@ -263,7 +263,7 @@ export class NotificationResolver { memberBannedFromChannelMailNotificationEnabled account.channelCreatedMailNotificationEnabled = channelCreatedMailNotificationEnabled - await em.save(notificationPreferences) + await em.save(account) return true } return false diff --git a/src/server-extension/resolvers/NotificationResolver/types.ts b/src/server-extension/resolvers/NotificationResolver/types.ts index 2687f9a74..5b578ecb5 100644 --- a/src/server-extension/resolvers/NotificationResolver/types.ts +++ b/src/server-extension/resolvers/NotificationResolver/types.ts @@ -8,95 +8,97 @@ export class NotificationArgs { @ArgsType() export class SetNotificationPreferencesArgs { @Field(() => Boolean, { nullable: false }) - commentCreatedInAppNotificationEnabled!: boolean + commentCreatedInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - commentTextUpdatedInAppNotificationEnabled!: boolean + commentTextUpdatedInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - openAuctionStartedInAppNotificationEnabled!: boolean + openAuctionStartedInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - englishAuctionStartedInAppNotificationEnabled!: boolean + englishAuctionStartedInAppNotificationEnabled: boolean + nftIssuedInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - nftIssuedInAppNotificationEnabled!: boolean + auctionBidMadeInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - auctionBidMadeInAppNotificationEnabled!: boolean + auctionBidCanceledInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - auctionBidCanceledInAppNotificationEnabled!: boolean + auctionCanceledInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - auctionCanceledInAppNotificationEnabled!: boolean + englishAuctionSettledInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - englishAuctionSettledInAppNotificationEnabled!: boolean + bidMadeCompletingAuctionInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - bidMadeCompletingAuctionInAppNotificationEnabled!: boolean + openAuctionBidAcceptedInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - openAuctionBidAcceptedInAppNotificationEnabled!: boolean + nftSellOrderMadeInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - nftSellOrderMadeInAppNotificationEnabled!: boolean + nftBoughtInAppNotificationEnabled: boolean + buyNowCanceledInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - nftBoughtInAppNotificationEnabled!: boolean + buyNowPriceUpdatedInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - buyNowCanceledInAppNotificationEnabled!: boolean + metaprotocolTransactionStatusInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - buyNowPriceUpdatedInAppNotificationEnabled!: boolean + channelRewardClaimedInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - metaprotocolTransactionStatusInAppNotificationEnabled!: boolean + channelRewardClaimedAndWithdrawnInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelRewardClaimedInAppNotificationEnabled!: boolean + channelFundsWithdrawnInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelRewardClaimedAndWithdrawnInAppNotificationEnabled!: boolean + channelPayoutsUpdatedInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelFundsWithdrawnInAppNotificationEnabled!: boolean + channelPaymentMadeInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelPayoutsUpdatedInAppNotificationEnabled!: boolean + memberBannedFromChannelInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelPaymentMadeInAppNotificationEnabled!: boolean + channelCreatedInAppNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - memberBannedFromChannelInAppNotificationEnabled!: boolean + commentCreatedMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelCreatedInAppNotificationEnabled!: boolean + commentTextUpdatedMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - commentCreatedMailNotificationEnabled!: boolean + openAuctionStartedMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - commentTextUpdatedMailNotificationEnabled!: boolean + englishAuctionStartedMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - openAuctionStartedMailNotificationEnabled!: boolean + nftIssuedMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - englishAuctionStartedMailNotificationEnabled!: boolean + auctionBidMadeMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - nftIssuedMailNotificationEnabled!: boolean + auctionBidCanceledMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - auctionBidMadeMailNotificationEnabled!: boolean + auctionCanceledMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - auctionBidCanceledMailNotificationEnabled!: boolean + englishAuctionSettledMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - auctionCanceledMailNotificationEnabled!: boolean + bidMadeCompletingAuctionMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - englishAuctionSettledMailNotificationEnabled!: boolean + openAuctionBidAcceptedMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - bidMadeCompletingAuctionMailNotificationEnabled!: boolean + nftSellOrderMadeMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - openAuctionBidAcceptedMailNotificationEnabled!: boolean + nftBoughtMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - nftSellOrderMadeMailNotificationEnabled!: boolean + buyNowCanceledMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - nftBoughtMailNotificationEnabled!: boolean + buyNowPriceUpdatedMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - buyNowCanceledMailNotificationEnabled!: boolean + metaprotocolTransactionStatusMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - buyNowPriceUpdatedMailNotificationEnabled!: boolean + channelRewardClaimedMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - metaprotocolTransactionStatusMailNotificationEnabled!: boolean + channelRewardClaimedAndWithdrawnMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelRewardClaimedMailNotificationEnabled!: boolean + channelFundsWithdrawnMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelRewardClaimedAndWithdrawnMailNotificationEnabled!: boolean + channelPayoutsUpdatedMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelFundsWithdrawnMailNotificationEnabled!: boolean + channelPaymentMadeMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelPayoutsUpdatedMailNotificationEnabled!: boolean + memberBannedFromChannelMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - channelPaymentMadeMailNotificationEnabled!: boolean + channelCreatedMailNotificationEnabled: boolean @Field(() => Boolean, { nullable: false }) - memberBannedFromChannelMailNotificationEnabled!: boolean + newChannelFollowerInAppNotificationPreferences: boolean @Field(() => Boolean, { nullable: false }) - channelCreatedMailNotificationEnabled!: boolean + newChannelFollowerMailNotificationPreferences: boolean }