Changeset 166a571 for protocols/twitter


Ignore:
Timestamp:
2016-04-01T18:06:15Z (8 years ago)
Author:
Flexo <nick@…>
Branches:
master
Children:
991c75f
Parents:
0d581bd
Message:

Avoid adding an id twice to the mutes list.

Twitter doesn't error if you mute the same user multiple times.

Also, correct signedness of the stringified user ids. bitlbee keeps them as
unsigned even if the json library uses signed for integers...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter_lib.c

    r0d581bd r166a571  
    954954       
    955955        /* Check this is not a tweet that should be muted */
    956         uid_str = g_strdup_printf("%" G_GINT64_FORMAT, status->user->uid);
     956        uid_str = g_strdup_printf("%" PRIu64, status->user->uid);
     957        if (getenv("BITLBEE_DEBUG")) {
     958                GSList *item;
     959                fprintf(stderr, "Checking mutes; this uid=%s\n", uid_str);
     960                for (item = td->mutes_ids; item != NULL; item = item->next) {
     961                        fprintf(stderr, "  id: %s\n", (char *)item->data);
     962                }
     963        }
    957964        if (g_slist_find_custom(td->mutes_ids, uid_str, (GCompareFunc)strcmp)) {
    958965                g_free(uid_str);
     
    11371144                }
    11381145        } else if (strcmp(type, "mute") == 0) {
    1139                 GSList *ids = td->mutes_ids;
     1146                GSList *found;
     1147                char *uid_str;
    11401148                ut = twitter_xt_get_user(target);
    1141                 ids = g_slist_prepend(ids,
    1142                                       g_strdup_printf("%" G_GINT64_FORMAT, ut->uid));
    1143        
    1144                 td->mutes_ids = ids;
     1149                uid_str = g_strdup_printf("%" PRIu64, ut->uid);
     1150                if (!(found = g_slist_find_custom(td->mutes_ids, uid_str,
     1151                                                  (GCompareFunc)strcmp))) {
     1152                        td->mutes_ids = g_slist_prepend(td->mutes_ids, uid_str);
     1153                }
     1154                twitter_log(ic, "Muted user %s", ut->screen_name);
     1155                if (getenv("BITLBEE_DEBUG")) {
     1156                        fprintf(stderr, "New mute: %s %"PRIu64"\n",
     1157                                ut->screen_name, ut->uid);
     1158                }
    11451159        } else if (strcmp(type, "unmute") == 0) {
    11461160                GSList *found;
    11471161                char *uid_str;
    11481162                ut = twitter_xt_get_user(target);
    1149                 uid_str = g_strdup_printf("%" G_GINT64_FORMAT, ut->uid);
     1163                uid_str = g_strdup_printf("%" PRIu64, ut->uid);
    11501164                if ((found = g_slist_find_custom(td->mutes_ids, uid_str,
    11511165                                                (GCompareFunc)strcmp))) {
     
    11531167                }
    11541168                g_free(uid_str);
     1169                twitter_log(ic, "Unmuted user %s", ut->screen_name);
     1170                if (getenv("BITLBEE_DEBUG")) {
     1171                        fprintf(stderr, "New unmute: %s %"PRIu64"\n",
     1172                                ut->screen_name, ut->uid);
     1173                }
    11551174        }
    11561175
Note: See TracChangeset for help on using the changeset viewer.