aboutsummaryrefslogtreecommitdiffstats
path: root/facebook/facebook-api.c
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2017-01-07 18:51:05 +0100
committerMarius Halden <marius.h@lden.org>2017-01-07 18:51:05 +0100
commitdfc6d6593cad26ffef63657b2abdd63a9420e2bb (patch)
tree621dcf0a9aae8f1d02f8ce8c2e1561e13d3bd943 /facebook/facebook-api.c
parent83702a89afa8575dbb155115eec57d6629e67748 (diff)
parent2707fa7895f33f3886616169073fc8b5fabfdd02 (diff)
downloadbitlbee-facebook-dfc6d6593cad26ffef63657b2abdd63a9420e2bb.tar.gz
bitlbee-facebook-dfc6d6593cad26ffef63657b2abdd63a9420e2bb.tar.bz2
bitlbee-facebook-dfc6d6593cad26ffef63657b2abdd63a9420e2bb.tar.xz
Merge branch 'master' into track-messages
Diffstat (limited to 'facebook/facebook-api.c')
-rw-r--r--facebook/facebook-api.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/facebook/facebook-api.c b/facebook/facebook-api.c
index 4a54e41..184cb89 100644
--- a/facebook/facebook-api.c
+++ b/facebook/facebook-api.c
@@ -436,6 +436,23 @@ fb_api_class_init(FbApiClass *klass)
1, FB_TYPE_ID);
/**
+ * FbApi::thread-kicked:
+ * @api: The #FbApi.
+ * @thrd: The #FbApiThread.
+ *
+ * Emitted upon the reply of a thread request when the user is no longer
+ * part of that thread. This is emitted as a result of #fb_api_thread().
+ */
+ g_signal_new("thread-kicked",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_ACTION,
+ 0,
+ NULL, NULL,
+ fb_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1, G_TYPE_POINTER);
+
+ /**
* FbApi::threads:
* @api: The #FbApi.
* @thrds: The #GSList of #FbApiThread's.
@@ -2535,6 +2552,7 @@ fb_api_thread_parse(FbApi *api, FbApiThread *thrd, JsonNode *root,
FbId uid;
FbJsonValues *values;
gboolean haself = FALSE;
+ guint num_users = 0;
GError *err = NULL;
values = fb_json_values_new(root);
@@ -2570,6 +2588,7 @@ fb_api_thread_parse(FbApi *api, FbApiThread *thrd, JsonNode *root,
while (fb_json_values_update(values, &err)) {
str = fb_json_values_next_str(values, "0");
uid = FB_ID_FROM_STR(str);
+ num_users++;
if (uid != priv->uid) {
user = fb_api_user_dup(NULL, FALSE);
@@ -2588,8 +2607,7 @@ fb_api_thread_parse(FbApi *api, FbApiThread *thrd, JsonNode *root,
return FALSE;
}
- if ((g_slist_length(thrd->users) < 2) || !haself) {
- fb_api_thread_reset(thrd, TRUE);
+ if (num_users < 2 || !haself) {
g_object_unref(values);
return FALSE;
}
@@ -2624,8 +2642,12 @@ fb_api_cb_thread(FbHttpRequest *req, gpointer data)
if (!fb_api_thread_parse(api, &thrd, node, &err)) {
if (G_LIKELY(err == NULL)) {
- fb_api_error(api, FB_API_ERROR_GENERAL,
- "Failed to parse thread information");
+ if (thrd.tid) {
+ g_signal_emit_by_name(api, "thread-kicked", &thrd);
+ } else {
+ fb_api_error(api, FB_API_ERROR_GENERAL,
+ "Failed to parse thread information");
+ }
} else {
fb_api_error_emit(api, err);
}