Why do I see "Not authorized to access this subscription" in SNS Console? - amazon-sns

I created an SNS topic in AWS. A third party subscribed their SQS to it. I'd like to now add a filter to the subscription from the console. But, when I click on their subscription I am taken to the details page where I see a red banner at the top of the page stating:
Couldn't retrieve subscription attributes. Error code:
AuthorizationError - Error message: Not authorized to access this
subscription
Given that it is my SNS topic, why can't I edit the filters on this page?
Would a better way to do this be to have the subscriber delete their subscription and then I create it on my side? Would that then give me permission to add filters?

Related

Telegram Bot Webhook doesn't track channel post deletion

I need to synchronize telegram channel posts with my site. So, I created a bot, a channel, added my bot to this channel(with admin rights, it has access to messages) and binded my bot's webhook to the specified server url. Everything goes well, post creation updates are correctly sent to the server url. The only problem is that the update of channel post deletion from telegram is not tracked, so admin has manually delete posts from the server database. Any idea, how to set up bot or webhook in order to track post deletion?
This is not possible using Bot API since Telegram doesn't send most of the events to Bot accounts.
You should instead use MTRPOTO to connect to a number on Telegram as a normal user (not a bot) that is the admin or subscriber of that channel and receive all of the events from Telegram.
I'd suggest you use Telethon (A Python MTPROTO library).
Upon a message deletion, you will receive MessageDeleted event.
There's an example on Telethon's document website:
from telethon import events
#client.on(events.MessageDeleted)
async def handler(event):
# Log all deleted message IDs
for msg_id in event.deleted_ids:
print('Message', msg_id, 'was deleted in', event.chat_id)
But if you insist on doing this with bot API, there's a spaghetti solution. You can forward channel posts to another chat with their Ids, if you get a message doesn't exist error, that means the message was deleted.

Firebase Stripe Extension - adding custom claims to user

I'm integrating Stripe with firebase and firestore using the Run Subscription Payments with Stripe extension. When a user subscribes to the service I need to be able to decode the JWT and see if they are subscribed or not through a custom claim.
The logs on the function show that it is invalidating the custom claim. I'm unsure why this is happening.
From the logs you've provided, it looks like you have multiple subscriptions (sub_KBpVfFzNclrhaG and sub_KBpV10rxE6jkkH) that are both tied to the same user/customer. Subscription sub_KBpVfFzNclrhaG has a status of active or trialing, and so the custom claim was correctly added. However, subscription sub_KBpV10rxE6jkkH was created shortly afterwards (I assume with a status that wasn't active or trialing) which updated the user's custom claim again to null. You can confirm that this is happening by checking the statuses of both Subscriptions in your dashboard.
You need to make sure you have only one active/trialing Subscription per-customer, which would be something you check in your app logic. There's an example of how to check for active/trialing subscriptions for a customer here (https://github.com/stripe-samples/firebase-subscription-payments/blob/4cf116c163ba69f0f46bcc782e4162e0edf452a4/public/javascript/app.js#L121)

StackDriver Error Reporting Email Notification

In our multitenant environment, I would like to setup an alert notification(e.g. email) when our user's code has an exception.
I was thinking of using the stackdriver error reporting api to send an error notification. Something like
from google.cloud import error_reporting
client = error_reporting.Client()
try:
raise NameError
except Exception:
client.report_exception()
How can I set this up (using a python api)
create an alert for a tenant id/service id to send notifications to. I could input user's contact email in this step.
Report an exception for a tenant id/service id using something like client.report_exception() and notify the alert mechanism
Other solutions:
This post suggests that I use logging and log errors, create a filter and create an alert policy. That would be an option but I feel it may be expensive as that would mean for each of the services of our users, it will be running the log search query every few seconds/minutes? I was wondering if there was a push approach (vs the logging pull approach) or have I misunderstood that the logging notification is actually a push approach?
If I'm on the wrong path, please feel free to suggest better ways.

Amazon SNS Filter control and access

Looking to setup a aws SNS topic - I intend to subscribe a third party to this topic and I’m hoping that I can use its message filtering to ensure said third party only gets the messages they need.
Is that possible? Since I control the SNS topic I’m hoping I can also control who gets to see what but the docs are not super clear.
From Amazon SNS Message Filtering - Amazon Simple Notification Service:
By default, an Amazon SNS topic subscriber receives every message published to the topic. To receive a subset of the messages, a subscriber must assign a filter policy to the topic subscription.
A filter policy is a simple JSON object containing attributes that define which messages the subscriber receives. When you publish a message to a topic, Amazon SNS compares the message attributes to the attributes in the filter policy for each of the topic's subscriptions. If any of the attributes match, Amazon SNS sends the message to the subscriber. Otherwise, Amazon SNS skips the subscriber without sending the message. If a subscription doesn't have a filter policy, the subscription receives every message published to its topic.

When to delete Push subscription from server

Just started playing with push notifications and I managed to handle all the subscription process and I'm saving endpoints and keys on my db. My questions is, what strategy should I follow, if any, to delete old subcription details from the database?.
So, if someone allowed notifications and they revoke the permission how do I know who did it to remove the details from the database?. Because if the user unsubscribes I'll just get a null subscription from pushManager.
For Pushpad we use these two strategies:
when a user revokes the permission the requests made using that endpoint will return 410 Gone and you should delete the endpoint
a developer can optionally trigger an unsubscribe with the Javascript SDK that will remove the endpoint from the server (this is useful for example to create a subscribe/unsubscribe button on the website)

Resources