It's possible to rewrite the expiration date of Telegram Premium subscription. Race condition with payment transactions.
Steps to reproduce
Activate 1 monthly subscription via App Store.
Wait for the next bill and fail the transaction (for example by "not enough funds").
Telegram will immediately terminate the premium status. The subscription is still alive in App Store and will be retried after fixing of payment details.
Use this delay between retries. Buy or receive the subscription. For example, someone will gift you Telegram Premium for 12 months.
Wait till App Store subscription renewal.
The expiration date of the premium is next month instead of next year from the gift.
After the end of App Store subscription, the premium is gone forever. The server doesn't restore the gifted one for 12 months.
Possible solutions
Don't be greedy
Many premium subscriptions like Spotify Premium, YouTube premium and so on are polite. They give a time to fix payment details and give you a few retries for payments. They don't stop immediately access to features and it saves from state desync between payments aggregators.
Prevent new transactions while others exist
This check already exists, but it doesn't pay attention to the status of already activated subscriptions. In the App Store it's possible to have an expired-like subscription and active at the same time.
Store multiple active subscriptions per account
It looks like the server stores only one active instance of subscription per user. And there is only one "expired at" field. If the races between platforms are difficult to be fixed, the solution with many "expired at" fields and sorting for the user's UI will be nicer than losing premium at all.
Notes
For already broken accounts it looks fine to add the "issues resolving" functionality to "restore purchahes" button instead of some kind of migrations in DB. I mean restore subscription by searching for gifts and transactions in other DB nodes.
I expect more issues with the same behaviors from other platforms like Google Play.
From the database perspective, you can investigate the issue by looking at my account. I'm one of the affected users.