Open joweste opened 9 months ago
What do you mean by contacts that are saved on our device?
What do you mean by contacts that are saved on our device?
No. I mean any contact not only saved in our device. For sample, I am member from some groups and your participants are contacts not saved in my device and I am unable to get your names or profile pictures url
What do you mean by contacts that are saved on our device?
No. I mean any contact not only saved in our device. For sample, I am member from some groups and your participants are contacts not saved in my device and I am unable to get your names or profile pictures url
All the data is in the store section
What do you mean by contacts that are saved on our device?
No. I mean any contact not only saved in our device. For sample, I am member from some groups and your participants are contacts not saved in my device and I am unable to get your names or profile pictures url
All the data is in the store section
Sorry, but I use baileys-bottle store and the participants name of the groups isn´t into store. There is in the store only the contacts saved into my device. The group members participants with name and profile url aren´t saved in contacts
Hi, Hi, I am trying to get the contact name of a jid when the jid is not intro store. I search all this discord group and I dont found a solution. But, I found a lib cobalt(java) in https://github.com/Auties00/Cobalt/blob/617bd77752648c994676a5834606d9378cb75033/src/main/java/it/auties/whatsapp/api/Whatsapp.java#L860 thats uses the code below. I am not fluent in java. If someone can adapt it to javascript, I think many of us will appreciate.
/**
* Queries the display name of a contact
*
* @param contactJid the non-null contact
* @return a CompletableFuture
*/
public CompletableFuture<Optional<String>> queryName(@NonNull ContactJidProvider contactJid) {
var contact = store().findContactByJid(contactJid);
if(contact.isPresent()){
return CompletableFuture.completedFuture(Optional.ofNullable(contact.get().chosenName()));
}
var query = new MexQueryRequest(List.of(new MexQueryRequest.User(contactJid.toJid().user())), List.of("STATUS"));
return socketHandler.sendQuery("get", "w:mex", Node.of("query", Json.writeValueAsBytes(query)))
.thenApplyAsync(this::parseNameResponse);
}
private Optional<String> parseNameResponse(Node result) {
return result.findNode("result")
.flatMap(Node::contentAsString)
.map(json -> Json.readValue(json, MexQueryResult.class))
.map(MexQueryResult::data)
.map(String::valueOf);
}
I have tried the next without success since I´m not a java guy:
[const number = +${p.id.replace("+", "")};
const content = [
{
tag: "query",
attrs: {},
content: [
{
tag: "users",
attrs: { user_id: number }
},
{
tag: "users",
attrs: { updates: ["STATUS"] }
}
]
}
];
const info = await wbot.query({
tag: "iq",
attrs: {
type: "get",
xmlns: "w:mex"
},
content
});
]
I'm the developer of cobalt, I'll add support here as well asap
hello, can I ask how to get catalog data and then send it
up
Hi,
I have also tried to replicate the logic and I'm getting back xwa2_users_updates_since
info with updates
.
Here is my code:
const result = await socket.query({
tag: 'iq',
attrs: {
to: S_WHATSAPP_NET,
type: 'get',
xmlns: 'w:mex',
},
content: [
{
tag: 'query',
attrs: {
// From Cobalt: https://github.com/nazarenoneto/Cobalt/blob/2340780c0378a8e769cee384a2c6a0989e4871a5/src/main/java/it/auties/whatsapp/model/request/MexQueryRequest.java#L10C15-L10C31
query_id: '6420453474633624',
},
content: new TextEncoder().encode(JSON.stringify({
variables: {
users: jids.map((jid) => ({ user_id: jid.split('@')[0].replace('+', '') })),
updates: ['STATUS'],
},
})),
},
],
});
console.log('Results', JSON.stringify(result, undefined, 2));
const resultNode = getBinaryNodeChild(result, 'result');
console.log('ResultNode', JSON.stringify(resultNode, undefined, 2));
But I'm a bit stuck at the moment as I don't find any relevant information. It seem I can only retrieve the "about" changes from there. And event that info is not always present.
I should implement USyncQuery here!
Before adding this issue, make sure you do the following to make sure this is not a duplicate:
Just describe the feature I think will be a plus if we had a function like whastweb.js to get contact name from a jid. The contact name is very important in whatever app.
For now, the alternative is using a store. But it doesn´t solve the problem because there are contacts such as group participants that aren´t in your contact list.
Regards, Luiz