aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2012-11-25 12:05:48 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2012-11-25 12:05:48 +0000
commit2cd8540c1076c3d0423abb1927bd47fdcbfbd382 (patch)
tree67480351ec580dac7d1a8a56b1f1a8d806d0bdeb /protocols
parent898c08e1d8abde8cc842ae619281b6cf4c1b7fdd (diff)
Show DMs the right way. With mode=many and show_ids=off they'll look just
like tweets but that's what you get with bad settings.. Also, don't show DMs from ourselves.
Diffstat (limited to 'protocols')
-rw-r--r--protocols/twitter/twitter_lib.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c
index 7048e6ae..676d804d 100644
--- a/protocols/twitter/twitter_lib.c
+++ b/protocols/twitter/twitter_lib.c
@@ -514,12 +514,14 @@ static struct twitter_xml_status *twitter_xt_get_status(const json_value *node)
/**
* Function to fill a twitter_xml_status struct (DM variant).
*/
-static gboolean twitter_xt_get_dm(const json_value *node, struct twitter_xml_status *txs)
+static struct twitter_xml_status *twitter_xt_get_dm(const json_value *node)
{
+ struct twitter_xml_status *txs;
const json_value *entities = NULL;
if (node->type != json_object)
return FALSE;
+ txs = g_new0(struct twitter_xml_status, 1);
JSON_O_FOREACH (node, k, v) {
if (strcmp("text", k) == 0 && v->type == json_string) {
@@ -543,7 +545,11 @@ static gboolean twitter_xt_get_dm(const json_value *node, struct twitter_xml_sta
txs->text = expand_entities(txs->text, entities);
}
- return txs->text && txs->user && txs->id;
+ if (txs->text && txs->user && txs->id)
+ return txs;
+
+ txs_free(txs);
+ return NULL;
}
static char* expand_entities(char* text, const json_value *entities) {
@@ -846,11 +852,11 @@ static gboolean twitter_stream_handle_object(struct im_connection *ic, json_valu
if ((txs = twitter_xt_get_status(o))) {
return twitter_stream_handle_status(ic, txs);
} else if ((c = json_o_get(o, "direct_message")) &&
- twitter_xt_get_dm(c, txs)) {
- GSList *output = g_slist_append(NULL, txs);
- twitter_private_message_chat(ic, output);
+ (txs = twitter_xt_get_dm(c))) {
+ if (strcmp(txs->user->screen_name, td->user) != 0)
+ imcb_buddy_msg(ic, txs->user->screen_name,
+ txs->text, 0, txs->created_at);
txs_free(txs);
- g_slist_free(output);
return TRUE;
} else if ((c = json_o_get(o, "event")) && c->type == json_string) {
twitter_stream_handle_event(ic, o);