libpurple/protocols/facebook/api.c

branch
facebook
changeset 37284
53cb588d8760
parent 37280
602a1c64670a
child 37285
2a5decfdeb7b
--- a/libpurple/protocols/facebook/api.c	Sat Jul 04 13:26:42 2015 -0400
+++ b/libpurple/protocols/facebook/api.c	Sun Jul 05 14:44:14 2015 -0400
@@ -1219,6 +1219,7 @@
 	FbApiPrivate *priv = api->priv;
 	FbApiThread thrd;
 	FbApiUser user;
+	gboolean haself;
 	gchar *str;
 	GError *err = NULL;
 	GList *elms = NULL;
@@ -1258,7 +1259,7 @@
 		FB_API_ERROR_CHK(api, err, goto finish);
 		elms2 = json_array_get_elements(arr2);
 
-		for (m = elms2; m != NULL; m = m->next) {
+		for (haself = FALSE, m = elms2; m != NULL; m = m->next) {
 			node2 = m->data;
 			fb_api_user_reset(&user, FALSE);
 
@@ -1268,6 +1269,7 @@
 			g_free(str);
 
 			if (user.uid == priv->uid) {
+				haself = TRUE;
 				continue;
 			}
 
@@ -1289,8 +1291,12 @@
 			continue;
 		}
 
-		mptr = fb_api_thread_dup(&thrd, FALSE);
-		thrds = g_slist_prepend(thrds, mptr);
+		if (haself) {
+			mptr = fb_api_thread_dup(&thrd, FALSE);
+			thrds = g_slist_prepend(thrds, mptr);
+		} else {
+			fb_api_thread_reset(&thrd, TRUE);
+		}
 	}
 
 	ret = g_slist_reverse(thrds);
@@ -1428,6 +1434,42 @@
 }
 
 void
+fb_api_thread_remove(FbApi *api, FbId tid, FbId uid)
+{
+	FbApiPrivate *priv;
+	FbHttpParams *prms;
+	gchar *json;
+	JsonBuilder *bldr;
+
+	static const FbApiHttpInfo info = {
+		fb_api_cb_http_bool,
+		"com.facebook.orca.protocol.a",
+		"removeMembers",
+		"DELETE"
+	};
+
+	g_return_if_fail(api != NULL);
+	priv = api->priv;
+
+	prms = fb_http_params_new();
+	fb_http_params_set_strf(prms, "id", "t_id.%" FB_ID_FORMAT, tid);
+
+	if (uid == 0) {
+		uid = priv->uid;
+	}
+
+	if (uid != priv->uid) {
+		bldr = fb_json_bldr_new(JSON_NODE_ARRAY);
+		fb_json_bldr_add_strf(bldr, NULL, "%" FB_ID_FORMAT, uid);
+		json = fb_json_bldr_close(bldr, JSON_NODE_ARRAY, NULL);
+		fb_http_params_set_str(prms, "to", json);
+		g_free(json);
+	}
+
+	fb_api_http_req(api, &info, prms, FB_API_URL_PARTS);
+}
+
+void
 fb_api_thread_topic(FbApi *api, FbId tid, const gchar *topic)
 {
 	FbHttpParams *prms;

mercurial