-
Notifications
You must be signed in to change notification settings - Fork 73
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
Notifications #2268
Notifications #2268
Conversation
c2c24fb
to
c364d7e
Compare
8d1e99c
to
cbd727d
Compare
cbd727d
to
a6f5108
Compare
src/datasources/push-notifications-api/entities/firebase-notification.entity.ts
Show resolved
Hide resolved
src/datasources/push-notifications-api/firebase-cloud-messaging-api.service.spec.ts
Outdated
Show resolved
Hide resolved
src/datasources/push-notifications-api/firebase-cloud-messaging-api.service.spec.ts
Outdated
Show resolved
Hide resolved
src/datasources/push-notifications-api/firebase-cloud-messaging-api.service.ts
Outdated
Show resolved
Hide resolved
src/routes/hooks/entities/schemas/executed-transaction.schema.ts
Outdated
Show resolved
Hide resolved
src/routes/notifications/v1/entities/__tests__/create-registration-v2.dto.builder.ts
Outdated
Show resolved
Hide resolved
src/routes/notifications/v1/entities/__tests__/create-registration-v2.dto.builder.ts
Outdated
Show resolved
Hide resolved
const signatureArray = safeV1Registration.signatures.length | ||
? safeV1Registration.signatures | ||
: [undefined]; | ||
for (const safeV1Signature of signatureArray) { | ||
if (safeV1Registration.safes.length) { | ||
const safeV2: Parameters< | ||
NotificationsServiceV2['upsertSubscriptions'] | ||
>[0] & { | ||
upsertSubscriptionsDto: { | ||
safes: Array<UpsertSubscriptionsSafesDto>; | ||
signature: `0x${string}`; | ||
}; | ||
} = { | ||
upsertSubscriptionsDto: { | ||
cloudMessagingToken: args.cloudMessagingToken, | ||
deviceType: args.deviceType, | ||
deviceUuid: (args.uuid as UUID) || undefined, | ||
safes: [], | ||
signature: (safeV1Signature as `0x${string}`) ?? undefined, | ||
}, | ||
authPayload: new AuthPayload(), | ||
}; | ||
} = { | ||
upsertSubscriptionsDto: { | ||
cloudMessagingToken: args.cloudMessagingToken, | ||
deviceType: args.deviceType, | ||
deviceUuid: (args.uuid as UUID) || undefined, | ||
safes: [], | ||
signature: safeV1Registration.signatures[0] as `0x${string}`, | ||
}, | ||
authPayload: new AuthPayload(), | ||
}; | ||
const uniqueSafeAddresses = new Set(safeV1Registration.safes); | ||
for (const safeAddresses of uniqueSafeAddresses) { | ||
safeV2.upsertSubscriptionsDto.safes.push({ | ||
address: safeAddresses as `0x${string}`, | ||
chainId: safeV1Registration.chainId, | ||
notificationTypes: Object.values(NotificationType), | ||
}); | ||
const uniqueSafeAddresses = new Set(safeV1Registration.safes); | ||
for (const safeAddresses of uniqueSafeAddresses) { | ||
safeV2.upsertSubscriptionsDto.safes.push({ | ||
address: safeAddresses as `0x${string}`, | ||
chainId: safeV1Registration.chainId, | ||
notificationTypes: Object.values(NotificationType), | ||
}); | ||
} | ||
safeV2Array.push(safeV2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per discussion, this is quite hard to follow.
We're not sure why [undefined]
is required for signatureArray
. I suggest adding some comments to begin with, and reconsidering multiple for
loops and/or making this more functional, e.g. using map
. (The latter can be done later, and we add a TODO for now.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up: [undefined]
is likely required as registrations may have no signature
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, because the signature can be empty when there is no signer key in the mobile app.
`gnosis-safe${args.registerDeviceDto.timestamp}${args.registerDeviceDto.uuid}${args.registerDeviceDto.cloudMessagingToken}${args.safeAddresses.sort().join('')}`, | ||
), | ||
), | ||
}, | ||
signature: args.safeV2Dto.upsertSubscriptionsDto.signature, | ||
}); | ||
} else { | ||
return await recoverAddress({ | ||
hash: keccak256( | ||
toBytes( | ||
`gnosis-safe${args.registerDeviceDto.timestamp}${args.registerDeviceDto.uuid}${args.registerDeviceDto.cloudMessagingToken}${args.safeAddresses.sort().join('')}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The messages are the same so let's move it to a variable.
As before: we should ensure clients use the same signing method when moving to v2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First part done 25045e4
About the second part: Please create a task for it so that we don't forget about it otherwise it's easy to miss it if we keep it as a review comment.
2a99e3b
to
51b896f
Compare
src/routes/notifications/v1/entities/__tests__/create-registration-v2.dto.builder.ts
Outdated
Show resolved
Hide resolved
90c854c
to
c25e69a
Compare
c25e69a
to
3dfb79d
Compare
3dfb79d
to
92675a4
Compare
Summary
This PR addresses and fixes multiple bugs related to the Notifications system, improving its reliability.
Changes
failed
to the multisig event