How I Query Graph API For Chat Id In Teams? - java

I am exporting Teams chat history to html and need to work out how to query for the chat name.
When I know the chat id I can get the chat with
graphClient.me().chats("19:xxxxgbl.spaces").messages()
I can then page through the collection and output all the chats.
However, I don't know how to get the chat id from the API in the first place.
I was able to find the first one from the Graph Explorer with /beta/me/chats and then searching the preview for a channel name and finding the name in the topic field.
The same section/value doesn't exist for one on one chats with a colleague though. When I search the output of /beta/me/chats for my colleagues name it doesn't find it.
When I scroll down the output I see it has a webUrl field. Clicking on the 3rd item of the response to /beta/me/chats shows me the 3rd chats in the sidebar of Teams.
How can I find the chat id with the Java API if I know my colleagues name that I am chatting with?

Have you tried using the Search endpoint https://learn.microsoft.com/en-us/graph/search-concept-chat-messages . You can query on To, From or use Participants which would return anything where the target either sends or received a chat message eg
POST https://graph.microsoft.com/v1.0/search/query
{
"requests": [
{
"entityTypes": [
"chatMessage"
],
"query": {
"queryString": "participants:blah#blah.com"
}
}
]
}
This then returns both the ChatId and the MessageId
There is also an Export API https://learn.microsoft.com/en-us/microsoftteams/export-teams-content (it has a cost involved) if you where doing things a tenant level.

Related

Telegram bot How to get link to user profile from a message they send

I'm working with telegram bot and i have this method to get user messages.
I need to find a way to get a link to the user who send this message
I saw there are this method, but i dont know how to connect them to a "link" to a profile
#Override
public void onUpdateReceived(Update update) {
update.getMessage().getFrom();
// i have: getFirstName(), getLastName() - not helping
// i have also getId() - but its a number how do i convert it to a link to telegram profile ?
}
Having username is optional on Telegram, setting it up means other people will be able to contact the user without knowing their phone number. Only users that chose their username in Telegram settings have a profile link, and the link is of the form https://t.me/<username>.
For ordinary messages, you can get the username via update.getMessage().getFrom().getUsername() and use it to create profile links, however, note that for many users this value will be empty (meaning they don't have a profile link).
Also, if you keep database of chat IDs, you can get usernames of the users via getChat Telegram API call. This can be useful because while usernames can be changed by the user any time (meaning their profile link will also change), chat ID of the user is constant over time and the getChat method will always provide you with the most recent information.

How to delete message from one side using firebase rules?

I work on chat app one to one chat and my database structure is
"rules": {
"Messages" :{
"$chatId" : {
".read": "root.child('Chat_members').child(chatId).child(auth.uid).exists()",
".write": "root.child('Chat_members').child(chatId).child(auth.uid).exists()"
}
I want to implement delete message so if user1 delete message i will hide it and display it only for user2 ,i can do this from client side but it is very inefficient way to request all data where there is for example just one message that will display for user1 how to do this from firebase rules? can I find any help?
As the documentation says security rules don't filter data. Instead you need to ensure that the client only reads the data you want to show.
I don't seen an easy way to do that to your structure without adding more data. In fact, the simplest way I can think of is to simply replicate the chat for each user and then actually delete the message from their data structure when needed.

Gmail API messages list odd behaviour

So I've recently been working on a server-side application which collects message lists from users, based on history id. I am doing full syncs.
Normally, I get responses like this:
{
"messages": [
{
"id": "14d9c91dbba84646",
"threadId": "14d9a7f9b36c65ae"
},
],
"nextPageToken": "14788016228466612591",
"resultSizeEstimate": 832
}
which is precisely what I get in 99% of cases. However, for some users, I get only this:
{"resultSizeEstimate":0}
with no other information. Note that this is on a full sync. I find this odd, because even on brand new email accounts, I receive the oldest information. One of the emails providing this result is an #yahoo.com email. Which in itself is not so odd, since non-gmail accounts can have OAuth credentials. However, normally when a user has no gmail inbox I instead get a 400 error with failedPrecondition. Can anybody provide some insight on this behaviour?

Facebook realtime api for feed

I have set up realtime feed update for user. So whenever a user comments or likes something, I get a update request from facebook.
{
object='user',
entry=[{
uid='1372299847',
id='1372299847',
time=1368760855,
changedFields=[feed]
}]
}
But this doesn't tell me what the update exactly was. I have to read that user's feed and see what is the new change and process it. If I get the id, then I can just request for that object and process it rather than reading his feed and getting the changes.
Is there any way to get what exactly was changed(id of the comment or status)?
Facebook doc says that you have to get the actual changeset via Graph API or FQL query. The notification you get tells you only the concerned user's ID.

Automatically adding users to roster using Smack API

I am building a client application for Intra Office Messaging System using Openfire as server. Using Roster class I can find the list of buddies (friends/contacts) using:
Roster rs= con.getRoster();
Collection<RosterEntry> list=rs.getEntries();
System.out.println("\n\n" + list.size() + " buddy(ies):");
for (RosterEntry r : list) {
System.out.println(r.getName());
}
But since this is an IOMS (Intra Office Messaging System), the requirement is diferent. There is no need to add contact. All users should see every other user and his status. Is there a way to achieve this?
One way to do this would be to integrating your openfire with AD. Add all users in a single common group and then import that group in the client. That way a user will automatically appear as a member of that group, and his/her online status will be available to all members of that group. And make sure whenever a new user is added, it becomes member of this group. This way everybody is imported at once in user's list.
Here is a reference link regarding same: Openfire Automatic Roster Population via Shared Groups and here is the guide to integrate Openfire with LDAP
Another way would be to update Openfire code and change registration process to add code for automatically adding all users to buddy list of the newly registered user. You can also do the same code on client side. But this is not a good path to walk on, as it will cause problem as the number of users in system grows.

Categories