diff options
-rw-r--r-- | protocols/twitter/twitter.c | 8 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.c | 13 |
2 files changed, 15 insertions, 6 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index fdfc83ec..91050578 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -591,7 +591,7 @@ static void twitter_handle_command(struct im_connection *ic, char *message) if (cmd[1] == NULL) twitter_status_destroy(ic, td->last_status_id); - else if (sscanf(cmd[1], "%" G_GUINT64_FORMAT, &id) == 1) { + else if (sscanf(cmd[1], "%" G_GINT64_MODIFIER "x", &id) == 1) { if (id < TWITTER_LOG_LENGTH && td->log) id = td->log[id].id; @@ -626,7 +626,7 @@ static void twitter_handle_command(struct im_connection *ic, char *message) /* Report nominally works on users but look up the user who posted the given ID if the user wants to do it that way */ if (g_str_has_prefix(cmd[1], "#") && - sscanf(cmd[1] + 1, "%" G_GUINT64_FORMAT, &id) == 1) { + sscanf(cmd[1] + 1, "%" G_GINT64_MODIFIER "x", &id) == 1) { if (id < TWITTER_LOG_LENGTH && td->log) { if (g_slist_find(ic->bee->users, td->log[id].bu)) { screen_name = td->log[id].bu->handle; @@ -654,7 +654,7 @@ static void twitter_handle_command(struct im_connection *ic, char *message) guint64 id = 0; if (g_str_has_prefix(cmd[1], "#") && - sscanf(cmd[1] + 1, "%" G_GUINT64_FORMAT, &id) == 1 && + sscanf(cmd[1] + 1, "%" G_GINT64_MODIFIER "x", &id) == 1 && (id < TWITTER_LOG_LENGTH) && td->log) { bu = td->log[id].bu; if (g_slist_find(ic->bee->users, bu)) @@ -664,7 +664,7 @@ static void twitter_handle_command(struct im_connection *ic, char *message) } else if ((bu = bee_user_by_handle(ic->bee, ic, cmd[1])) && (tud = bu->data) && tud->last_id) { id = tud->last_id; - } else if (sscanf(cmd[1], "%" G_GUINT64_FORMAT, &id) == 1 && + } else if (sscanf(cmd[1], "%" G_GINT64_MODIFIER "x", &id) == 1 && (id < TWITTER_LOG_LENGTH) && td->log) { bu = td->log[id].bu; if (g_slist_find(ic->bee->users, bu)) diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index 862104f5..f4c81e0c 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -66,7 +66,8 @@ struct twitter_xml_status { time_t created_at; char *text; struct twitter_xml_user *user; - guint64 id, reply_to; + guint64 id, rt_id; /* Usually equal, with RTs id == *original* id */ + guint64 reply_to; }; /** @@ -490,6 +491,7 @@ static struct twitter_xml_status *twitter_xt_get_status(const json_value *node) if (rtxs) { g_free(txs->text); txs->text = g_strdup_printf("RT @%s: %s", rtxs->user->screen_name, rtxs->text); + txs->rt_id = txs->id; txs->id = rtxs->id; txs_free(rtxs); } @@ -641,6 +643,12 @@ static char *twitter_msg_add_id(struct im_connection *ic, td->log[td->log_id].id = txs->id; td->log[td->log_id].bu = bee_user_by_handle(ic->bee, ic, txs->user->screen_name); + /* This is all getting hairy. :-( If we RT'ed something ourselves, + remember OUR id instead so undo will work. In other cases, the + original tweet's id should be remembered for deduplicating. */ + if (txs->rt_id && strcmp(txs->user->screen_name, td->user) == 0) + td->log[td->log_id].id = txs->rt_id; + if (set_getbool(&ic->acc->set, "show_ids")) { if (reply_to != -1) return g_strdup_printf("\002[\002%02x->%02x\002]\002 %s%s", @@ -1153,8 +1161,9 @@ static void twitter_http_post(struct http_request *req) if (!(parsed = twitter_parse_response(ic, req))) return; - if ((id = json_o_get(parsed, "id")) && id->type == json_integer) + if ((id = json_o_get(parsed, "id")) && id->type == json_integer) { td->last_status_id = id->u.integer; + } json_value_free(parsed); } |