Is there a way to get list of IDs (or messages directly) which have been forwarded in some thread? I've been trying to access attachment column in FQL table but it doesn't contain anything. I've been trying to search for some kind of answer to this for a while but haven't found anything that would help me. I'm currently using this FQL query:
SELECT attachment,message_id,author_id,body,created_time FROM message WHERE thread_id = ID
Is there a way to get forwarded messages from message table?
No, the actual (and old) message table won't let you access to the forwarding information. Indeed, the forwarding system looks quite new.
However, you'll soon be able to work with it when the new unified_message table will be available. I guess these unified_ tables are still not entirely deployed. But you can already use them as development and test purposes.
Please note: We are in the process of making the new messages system
available to all users, at which point this table will replace the
existing message table. We are providing early access to this API for
registered developer accounts only until the new messaging system is
broadly available. You should use the message table for production
applications at the current time.
Related
I am developing a small REST API. As I got into analyzing all the possible failure scenarios, which I have to handle to create a reliable and stable system, I went into thinking about how to make my APIs atomic.
If we take a simple case of creating a contact through the POST API.
The server gets the POST request for the new contact.
Creates the contact in the DB.
Creates a response to send back to the client.
The server crashes before sending the response.
The client gets a timeout error (or connection refused?)
The client is bound to think that the contact creation has failed, though, in fact, the contact was in the DB.
Is this a rare case we can ignore? How do big companies deal with such an issue?
To handle this, you should make your write APIs idempotent i.e. If the same operation is executed multiple times, the result should be same as the operation was done only once.
To achieve this in your current example, you need to be able to identify a contact uniquely based on some parameter, say emailAddress. So, if the createContact is called again with the same emailAddress, check in the DB if a contact already exists with the emailAddress. If so, return the existing contact. Else, create a new contact with the emailAddress and return it.
Hope this helps.
If the request times out, the client should not make any assumption about whether it failed or succeeded.
If it is just a user making a request from a web form, then the timeout should just be exposed to the user, and they can hit the back button and check whether the operation succeeded or not, and if not they submit the request again. (This is fine as long as you always keep a consistent state. If your operation has multiple steps and fails mid way, you need to roll back.)
However if reliable messaging is important to your application you will have to use a library or build your own reliable messaging layer. This could work by having the client assign a unique ID to every request, and having another request that lets you check the result of that request ID later. Then you can do automated retries but only where necessary.
I have a scenario for my app which is similar to sending friend request in Facebook.
When user A sends friend request to user B, internally a new friend request document is created. At a later time when user B also wants to send friend request to A, system would find out that a friend request document existed and so they should be friend of each other, no new friend request document would be created.
I'm trying to figure out the case when user A and user B both simultaneously sends friend request to each other which will then create 2 friend request documents and leading to undetermined behaviour...
Thanks for your suggestions.. Really appreciated!
Edit:
A few had suggested to use a request queue to solve this; however,
I'm confused about using queue because i thought it would make my rest api endpoint process requests sequentially. Wouldn't I lose all the benefit of multi-threading by using queue? I can't help but imagine how bad it would be if my service has millions of requests queued and waiting to be executed one by one just due to this issue. Has anyone seen something along similar problems seen in production?
I had similar situation with my client which has concurrent writes in the database, What I have implemented is a Queue service.
Create a request in the queue rather than writing in the database, a separate reader will
read one message from the queue at a time and check if it is valid to write it to
database, write only if there is no previous request.
You can implement your own queue or you can use service like AWS-SQS, rabbitmq, MSMQ etc.
// Specific to your case
In mongodb write operations on a single document are atomic.
mongodb has a feature of unique index.
Hence if you insert the document with an _id(or any other unique index) with person names A and B by creating unique index for both (such as "A_B" by lexicographically sorting the names) before doing insertion. You will inherently be able to insert only one instance of that document.
// General
What essentially we would like to have are transactions but since mongodb doesn't support such, as of now. There are a few tricks to achieve this:
2 phase commits :
https://docs.mongodb.org/v3.0/tutorial/perform-two-phase-commits/
Using an external source to maintain a flag, for example using memcache which supports insertion in transactional manner/Compare and Swap.
Here if you use system calls method in frontend then you should fire one request to frontend from Database when some user like, I send you request then within a sec database send you one system call and your frontend code immediate correct the button text like
"Add a friend" to "incoming request"
or else.
if you are only setting up database then just make a system call which send it to UI when friend request arrives or as you say Document created, the further process will be handled by UI Developer.
Thank you.
if you don't like the answer then I m apologize for that but don't downvote me because I M new in Stack Overflow Community.
I'm building an application for my personal use that saves all my facebook messages in a database on my computer.
But I have a problem as it seems only few messages can be accessed through the Graph API.
I created a token with all the possible permissions.
When issuing a call:
/me/inbox
I get all the threads in my inbox but for some of them the comments field which contains the actual messages is missing. It's mostly for conversation with people that are not friend with me on facebook.
For those threads, when I try to get more information by /<id_of_the_thread>
I get an error (code 100) Unsupported get request. from the graph api.
Is it a normal behaviour of the API?
What am I missing here?
Don't hesitate if you know a better way of saving all my messages.
Another, somewhat inferior, but much more accessible way of obtaining one's Facebook messages is by downloading a copy of your Facebook data through https://www.facebook.com/settings. This way you can download an archive with all your FB data, including your messages. They are however capped to 10,000 messages per conversation, and are all stored in one .htm file, which is not very practical if you want to do further operation on them.
No i think, we can't specified the Thread by using ID, but commonly i'm sorting the threads by its sender. CMIIW
Do anyone know when the following FQL tables will be opened for all users and not only for developers?
unified_thread
unified_message
According to the documentation below, Facebook do plan to open these FQL tables:
Please note: We are in the process of making the new messages system available to all users, at which point this table will replace the existing thread table. We are providing early access to this API for registered developer accounts only until the new messaging system is broadly available.
http://developers.facebook.com/docs/reference/fql/unified_thread/
This message no longer appears above so you can assume that it is open for all.
Also the new messaging system has been rolled out for a while now.
I have got an Openfire Jabber server with in excess of 75,000 users listed. Of those, 150 or more can be online at any one time.
Is there anywhere that I can collect the JIDs (usernames) of the currently logged in users? I have full database access to the underlying data, but the server does not appear to write the current status back to the DB. Because of the number of users, rosters are not being used.
A very useful set of data being returned would be from a simple (password protected) webpage with one JID per line, optionally with the login time, and maybe also the last time that account performed an action [like send a message]. The latter two are not as essential, but would be useful if the data is available, as well as any other information that was available regarding the user session.
dont know if this will help but I ran into it looking for similar functionality. As defined in XEP-0045 http://xmpp.org/extensions/xep-0045.html#disco-roominfo :
An implementation MAY return a list of existing occupants if that information is publicly
available, or return no list at all if this information is kept private. Implementations
and deployments are advised to turn off such information sharing by default.
So you would need to ensure it works as advertised on Openfire (all xmpp servers ive come across have a bug or two in them), and I imagine you would need to code some logic to get the results.
Good luck.
Not a perfect answer, but the query you want is probably embedded in the session-summary.jsp page. I got to it on a locally hosted server at http://localhost:9090/session-summary.jsp. What I don't know is if that is then stored in the database where it is query-able, or if it is stored internally to the client. The latter is more likely.
The data that page displays is Name, Resource, Status, Presence, Priority, Client IP, and Close Connection.