aboutsummaryrefslogtreecommitdiffstats
path: root/facebook/facebook.c
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2017-01-07 12:55:26 -0300
committerdequis <dx@dxzone.com.ar>2017-01-07 12:55:26 -0300
commit2707fa7895f33f3886616169073fc8b5fabfdd02 (patch)
tree92434f7c3c9ea41d75bd7b800e250716f49cb528 /facebook/facebook.c
parent878c1dc70a3a5838e2f2ed18be0643696f5c8b92 (diff)
downloadbitlbee-facebook-2707fa7895f33f3886616169073fc8b5fabfdd02.tar.gz
bitlbee-facebook-2707fa7895f33f3886616169073fc8b5fabfdd02.tar.bz2
bitlbee-facebook-2707fa7895f33f3886616169073fc8b5fabfdd02.tar.xz
Don't disconnect when trying to join a chat after being kicked
This replaces a subset of "Failed to parse thread information" (the ones that aren't really a problem parsing) with "You have been removed from this chat" appearing in the relevant chat window.
Diffstat (limited to 'facebook/facebook.c')
-rw-r--r--facebook/facebook.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/facebook/facebook.c b/facebook/facebook.c
index 55f9c37..4ef9fc9 100644
--- a/facebook/facebook.c
+++ b/facebook/facebook.c
@@ -571,6 +571,33 @@ fb_cb_api_thread_create(FbApi *api, FbId tid, gpointer data)
}
static void
+fb_cb_api_thread_kicked(FbApi *api, FbApiThread *thrd, gpointer data)
+{
+ FbData *fata = data;
+ gchar id[FB_ID_STRMAX];
+ gchar *topic;
+ struct groupchat *gc;
+ struct im_connection *ic;
+
+ FB_ID_TO_STR(thrd->tid, id);
+ ic = fb_data_get_connection(fata);
+ gc = bee_chat_by_title(ic->bee, ic, id);
+
+ if (G_UNLIKELY(gc == NULL)) {
+ return;
+ }
+
+ topic = fb_thread_topic_gen(thrd);
+ imcb_chat_topic(gc, NULL, topic, 0);
+ g_free(topic);
+
+ imcb_chat_log(gc, "You have been removed from this chat");
+
+ fb_data_remove_groupchat(fata, gc);
+ imcb_chat_free(gc);
+}
+
+static void
fb_cb_api_threads(FbApi *api, GSList *thrds, gpointer data)
{
FbApiThread *thrd;
@@ -744,6 +771,10 @@ fb_login(account_t *acc)
G_CALLBACK(fb_cb_api_thread_create),
fata);
g_signal_connect(api,
+ "thread-kicked",
+ G_CALLBACK(fb_cb_api_thread_kicked),
+ fata);
+ g_signal_connect(api,
"threads",
G_CALLBACK(fb_cb_api_threads),
fata);