Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newsletter w:mex queries receive bad request nodes on most endpoints #539

Open
Thomas-Pellan opened this issue Jan 13, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@Thomas-Pellan
Copy link

Hello,

While trying to query a channel info, join or leave a channel the following node is sent back by whatsapp :

{"data":null,"errors":[{"message":"Bad Request","path":[],"extensions":{"error_code":400,"severity":"CRITICAL","is_retryable":false}}]}

My test code :

//Extracted from sockerhandler
private CompletableFuture<Node> sendQuery(String id, Jid to, String method, String category,
                                        Map<String, Object> metadata, Node... body) throws CobaltApiNotFoundException {
        var attributes = Attributes.ofNullable(metadata)
                .put("xmlns", category, Objects::nonNull)
                .put("id", id, Objects::nonNull)
                .put("to", to)
                .put("type", method)
                .toMap();
        return 
                api.sendNode(Node.of("iq", attributes, body));
    }     

//Extracted from sockethandler
private CompletableFuture<Node> sendQuery(String method, String category, Node... body) {
        return sendQuery(null, JidServer.WHATSAPP.toJid(), method, category, null, body);
    }

public String test() {
var key = new QueryNewsletterRequest.Input(Jid.of(jidStr), "JID", NewsletterViewerRole.GUEST);
        var request = new QueryNewsletterRequest(new QueryNewsletterRequest.Variable(key, true, true, true));

        CompletableFuture<Optional<String>> future = sendQuery("get", "w:mex", Node.of("query",
                Map.of("query_id", "6620195908089573"),
                        Json.writeValueAsBytes(request)))
                .thenApply(result -> result.findChild("result")
                .flatMap(Node::contentAsString));

        return future.join().orElse(null);
}   

This seems to happen on joinNewsletter/leaveNewsletter/queryNewsletterSubscriber/queryNewsletter so most of the w:mex message types.

I tried to change the queryids with some coming from WhiskeySockets's Baileys but with no success. joinNewsletter/leaveNewsletter seems to not work for them too, but get channel meta data does.

version tested : 0.0.7

@Auties00 Auties00 added the bug Something isn't working label Jan 13, 2025
@Thomas-Pellan
Copy link
Author

Update on this after further testing :

queryNewsletter : the reason for the bad request seems to be the boolean fetchFullImage in QueryNewsletterRequest.Variable, when switching it to false the request responds normally

working eg :

var key = new QueryNewsletterRequest.Input(Jid.of(jidStr), "JID", NewsletterViewerRole.GUEST);
var request = new QueryNewsletterRequest(new QueryNewsletterRequest
                .Variable(key, true, false, true));

CompletableFuture<Node> future = sendQuery("get", "w:mex", Node.of("query",
                        Map.of("query_id", "6620195908089573"),
                        Json.writeValueAsBytes(request)));

return future.join();

join/leave newsletter : seems to work when testing with a phone to validate the subscription, error was in my code sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants