dimanche 3 janvier 2021

Checking subscription status realtime

Consider sample chat application where user purchase monthly/annual subscriptions (subscriptions like Amazon Prime, etc).

As soon as the subscription expires, user should not be able to send messages in app.

User can end their subscription before the original subscription end date.

One solution in my mind (Frontend) - to cache the end date in app and before every "send message" operation, compare the end date and current date.

But the problem is - if user ends the subscription early, user will still be able to send the message.

How can I push update the new subscription end date in cache.

Another solution was (Backend) - I have a table in backend storing subscription details like subscription_id, user_id, subscription_enddate. So before any "send message" operation, query the subscription table and compare the dates and then continue/cancel further operations.

Q1. Should I go with Backend solution or can you please share some improvements to frontend method or any best practice for this scenario?

Q2. Also is storing subscription details in separate table best practice or any good design instead. ?

PS- Sample chat app is based on AWS Amplify Datastore

Thanks.

Aucun commentaire:

Enregistrer un commentaire