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

Backend: new fcm contract #268

Open
wants to merge 8 commits into
base: backend
Choose a base branch
from

Conversation

Red1tum
Copy link
Collaborator

@Red1tum Red1tum commented May 21, 2024

We receive the google's calendar id from header by which we can find our workspace. Then we will fetch all booking for this workspace for one week from now. We will send the workspace with bookings in batches if there are too many of bookings (see companion object to see how we check if there are too many). These messages will have unique id so that the receiver of these messages could detect if it's continuation or new message.

I'm not sure about converter implementation, so open to suggestions.
I'm also thinking on adding new repository for bookings (specifically for this sender), because the current one's getting more information than we really need (integration, etc). So removing these joins could improve performance of this sender a bit.

)

if (bookings.isEmpty()) {
logger.info("[fcmNotificationSender] Bookings on 1 week from now for {} workspace were empty", workspace.name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the class is automatically specified by the log. The name of the method should be specified at the beginning of the message: [sendUpdateContentMessages]

@@ -29,6 +45,58 @@ class FcmNotificationSender(private val fcm: FirebaseMessaging): INotificationSe
.build()
fcm.send(msg)
}

override fun sendUpdateContentMessages(topic: String, resourceId: String) {
logger.info("[fcmNotificationSender] Received update on {} calendar id", resourceId)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the class is automatically specified by the log. The name of the method should be specified at the beginning of the message: [sendUpdateContentMessages]

)
}
}
logger.info("[fcmNotificationSender] {} messages have been sent, {} of them successful, {} - failures",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[handleFcmResponses]*


val messageId = UUID.randomUUID().toString()
val messageBatches = bookings.chunked(MAX_BOOKING_EVENTS_IN_MESSAGE) { bookingList ->
val fcmWorkspace = FcmWorkspaceWithBookingsDTOModelConverter
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually inject converters through DI.

@Red1tum
Copy link
Collaborator Author

Red1tum commented Jun 5, 2024

It turns out that batch endpoint will be deprecated on 21st of june this year and they are suggesting to implement your own batch strategy using their '/send' endpoint, but it would be much less efficient (using batch endpoint all messages were sent in 1 request).
So I decided to go with a different strategy for contract and send the modified workspace instead of sending all bookings for modified workspace.

@Red1tum Red1tum force-pushed the backendApp/feature/new-fcm-contract branch from 7396aa4 to a11cd3d Compare June 6, 2024 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants