How do i stop push notifications when user is already in the chat room - websocket

i need some help with the sudo code logics to how i could build a messaging feature, where when the user is already viewing the chat/chatroom, he does not see notifications (push/websockets) being sent to him for that particular chat room, but still will be receiving notifications from other chat/chatroom.

Related

Push notification appears after one user messages another user using firebase and xcode

If I were to make a messaging app which would involve a user recieving a notification after being messaged by another user, how could i go about setting up the notifications in such a way where they are sent after the message is sent by the user who sent it. If someone could point me in the right direction that would be awesome thank you.
P.S. I am using cloud messaging

What happens to the activity if my end point is not accessible or returns a 500?

I have a Microsoft bot app that can be installed in Teams on a team.
For now, I save the tenant ID + team id in our DB when the app gets installed, via a received activity on our end point.
What happens if my prod is not up at the moment of the installation? (for whatever reason, could be an update or just a technical downtime...)
Is it lost forever? Is it retried?
Same question with a 500 error?
This activity is an example, it could be any other activity. Ex: a user is added/removed, a message has been sent etc...
For OnMembersAddedAsync; unfortunately there is no retry from the Teams side, it fires and forgets.
The information in that Activity will be included in any subsequent send from Teams - so the bot can recover, if the user interacts with the bot again. Messages would just be sent when the bot recovers.
You can find a bit more info on Teams and events here:
How do I send a 1:1 welcome message?

Is there a way to keep my Slack App from being used in Channels?

Is there a way to keep my Slack App from being used in Channels?
I only want the current user to be able to interact with the App directly and it not to show in any channels.
When setting up a app in MS Teams using App Studio there is a option that lets you limit the App to "Personal" I'm looking for something similar in Slack.
I am not sure what use cases you want to prohibit exactly, but in general your app can check each incoming request and decide if and how it wants to react to it.
For example you will always get the user ID of who sent the slash command or message to the bot. You can use that to filter our users that should not have access.
Update
To restrict your app the the app channel you need to do the following:
When receiving a request from the user, first open a direct message channel to the user from the bot user. That will always give you the channel ID of the app channel.
Then reply with a direct message in that app channel
or alternatively check if the received request is from the app channel and ask the user to only talk in app channel if it is not.
See also this answer on how this works in detail.

Google Calendar push notifications are sent to all participants when one participant responds to an event

When using Google Calendar API push notification, suppose, sender A sends a meeting invite to B and C. When B accepts the meeting invite, C also receives a push notification.
This can be problematic in cases where a meeting invite is sent to a lerge number of recipients, say 200 people. In this case each of the 200 recipients of the invite will also see 200 push notifications only due to other recipients accepting or declining the event.
Is there a way to get push notifications only in case an event's start or end time is changed or event is deleted but not receive push notifications when recipients accept/decline an event?
With Office365 API, I do not see push notifications being sent in this scenario.
The Google Calendar API provides push notifications that let you watch for changes to resources.
A resource is changed if anything if it is updated or deleted and in this case if a user accepts or declines.
Answer: No you cant pick You get all the changes you do not get to pick which changes you want. You get notified of all changes on a resource. I suggest that you filter out the changes that you dont want locally.

How do I receive only the messages that are direct messages to my bot user?

I have successfully setup my slack bot app, have enabled events etc. I want to receive any direct messages that the members of my slack team send to my bot. For this, I have only enabled Bot Events and No Team Events like below
However, I do not get any event on my webhook on this setting.
If I enable message.im event under Team Events, then I start getting events. But then, I get every message that the user (who has installed the app) sends to any other user in the team.
How do I get only the messages that are sent to my bot user?
Update 1
Based on this SO question I created a private channel with the bot user. Even then, the messages in the private channel do not arrive in my webhook with the above event subscriptions.
Update 2
After reinstalling the app, it seems to be working fine. I have only used it for few minutes after the reinstall so far. I will keep posting here how it goes. It would still be interesting to know what went wrong where.
It is normal behavior that your script receives all messages (for every channel your bot is a member of), not only the messages sent directly to your bot. At this time you can not filter further in the event configuration. So you need to filter out any unwanted message in your script handling the event.
See also this answer.

Resources