Changeset 67f6828 for protocols


Ignore:
Timestamp:
2012-11-25T22:09:41Z (11 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
b235228
Parents:
f97b8e9
Message:

Only a few commands use twitter_message_id_from_command_arg(), others were
still using a decimal scanf format string. Messy code duplication. :-(

Location:
protocols/twitter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.c

    rf97b8e9 r67f6828  
    592592                if (cmd[1] == NULL)
    593593                        twitter_status_destroy(ic, td->last_status_id);
    594                 else if (sscanf(cmd[1], "%" G_GUINT64_FORMAT, &id) == 1) {
     594                else if (sscanf(cmd[1], "%" G_GINT64_MODIFIER "x", &id) == 1) {
    595595                        if (id < TWITTER_LOG_LENGTH && td->log)
    596596                                id = td->log[id].id;
     
    627627                   posted the given ID if the user wants to do it that way */
    628628                if (g_str_has_prefix(cmd[1], "#") &&
    629                     sscanf(cmd[1] + 1, "%" G_GUINT64_FORMAT, &id) == 1) {
     629                    sscanf(cmd[1] + 1, "%" G_GINT64_MODIFIER "x", &id) == 1) {
    630630                        if (id < TWITTER_LOG_LENGTH && td->log) {
    631631                                if (g_slist_find(ic->bee->users, td->log[id].bu)) {
     
    655655
    656656                if (g_str_has_prefix(cmd[1], "#") &&
    657                     sscanf(cmd[1] + 1, "%" G_GUINT64_FORMAT, &id) == 1 &&
     657                    sscanf(cmd[1] + 1, "%" G_GINT64_MODIFIER "x", &id) == 1 &&
    658658                    (id < TWITTER_LOG_LENGTH) && td->log) {
    659659                        bu = td->log[id].bu;
     
    665665                    (tud = bu->data) && tud->last_id) {
    666666                        id = tud->last_id;
    667                 } else if (sscanf(cmd[1], "%" G_GUINT64_FORMAT, &id) == 1 &&
     667                } else if (sscanf(cmd[1], "%" G_GINT64_MODIFIER "x", &id) == 1 &&
    668668                           (id < TWITTER_LOG_LENGTH) && td->log) {
    669669                        bu = td->log[id].bu;
  • protocols/twitter/twitter_lib.c

    rf97b8e9 r67f6828  
    6767        char *text;
    6868        struct twitter_xml_user *user;
    69         guint64 id, reply_to;
     69        guint64 id, rt_id; /* Usually equal, with RTs id == *original* id */
     70        guint64 reply_to;
    7071};
    7172
     
    491492                        g_free(txs->text);
    492493                        txs->text = g_strdup_printf("RT @%s: %s", rtxs->user->screen_name, rtxs->text);
     494                        txs->rt_id = txs->id;
    493495                        txs->id = rtxs->id;
    494496                        txs_free(rtxs);
     
    642644        td->log[td->log_id].bu = bee_user_by_handle(ic->bee, ic, txs->user->screen_name);
    643645       
     646        /* This is all getting hairy. :-( If we RT'ed something ourselves,
     647           remember OUR id instead so undo will work. In other cases, the
     648           original tweet's id should be remembered for deduplicating. */
     649        if (txs->rt_id && strcmp(txs->user->screen_name, td->user) == 0)
     650                td->log[td->log_id].id = txs->rt_id;
     651       
    644652        if (set_getbool(&ic->acc->set, "show_ids")) {
    645653                if (reply_to != -1)
     
    11541162                return;
    11551163       
    1156         if ((id = json_o_get(parsed, "id")) && id->type == json_integer)
     1164        if ((id = json_o_get(parsed, "id")) && id->type == json_integer) {
    11571165                td->last_status_id = id->u.integer;
     1166        }
    11581167       
    11591168        json_value_free(parsed);
Note: See TracChangeset for help on using the changeset viewer.