samuelgozi/firebase-firestore-lite

Realtime updates (not an issue, just easiest way to point something out)

Opened this issue · 0 comments

Howdy folks,

I've been working on a very similar implementation for the Godot game engine, as I'm the creator of the main Firebase library for said engine use. I noticed a message from Samuel Elgozi here:

https://groups.google.com/g/firebase-talk/c/WpfsvysNFCU/m/GArEBbyEBAAJ

When I saw it, it looked very familiar to me. I noticed however that I believe there's a typo in it due to the very weird shape of the API for Firestore.Listen. Essentially, I've come to the conclusion in my own experiments that it has to look like this:

var body = {
  "addTarget": {
    "documents": {
      "documents": ["projects/%s/databases/(default)/documents/%s/%s" % [project_id, collection_path, document_id]]
    }
  }
}

You can ignore all the %s and just ensure that they are replaced in your version with the appropriate values to the right, the above is just how my implementation substitutes those values into the string.

It's pretty bizarre, but what I noticed is that there's a documents object that has a child node named documents array. I've gotten mine working to the point that I do receive a response from the servers, but for some reason, it never returns any actual content, even though I've perfectly modeled my request after inspecting a valid request from a web app using Chrome dev tools. I'm not really sure what's different, but I figure if you're using web, you might well be able to figure out exactly what's wrong if the body json is formatted correctly and be able to help me in turn. (The above isn't necessarily going to work for you, as I noticed it seems to be pretty weird about which headers are sent, and I'm not sure if my "auth bearer" and "content type json" are enough for that. It seems like they must not be, and I suspect it doesn't accept json as an endpoint, because the valid web request I made encodes the body as an x-www-form-urlencoded query string and sends that as the body.)

Anyway, I hope this might be helpful! If it's not, sorry for opening an issue, was the only easy way I could find what I know to be the right person/group responsible for the library!

P.S. I just learned that the reason it doesn't work in Godot yet is because the HTTPClient does not support HTTP2! Doh! Guess I'll either open a proposal or get someone else to on that repo. I still hope this helps! I guess you should not have the HTTP2 problem. :P Note you may also have to pass the pseudo-headers required for it, not sure if your system will do it automatically.