Ignore:
Timestamp:
2015-05-09T19:50:30Z (9 years ago)
Author:
dequis <dx@…>
Children:
ec8b369
Parents:
356e2dd (diff), 5014380 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'develop' into feat/hip-cat

Conflicts:

protocols/jabber/hipchat.c
protocols/jabber/iq.c
protocols/jabber/jabber.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.c

    r356e2dd rb8c336b  
    483483}
    484484
    485 static gboolean twitter_length_check(struct im_connection *ic, gchar * msg)
    486 {
    487         int max = set_getint(&ic->acc->set, "message_length"), len;
    488         int target_len = set_getint(&ic->acc->set, "target_url_length");
     485int twitter_message_len(gchar *msg, int target_len)
     486{
    489487        int url_len_diff = 0;
    490488
     
    493491        }
    494492
    495         if (max == 0 || (len = g_utf8_strlen(msg, -1) + url_len_diff) <= max) {
     493        return g_utf8_strlen(msg, -1) + url_len_diff;
     494}
     495
     496static gboolean twitter_length_check(struct im_connection *ic, gchar * msg)
     497{
     498        int max = set_getint(&ic->acc->set, "message_length");
     499        int target_len = set_getint(&ic->acc->set, "target_url_length");
     500        int len = twitter_message_len(msg, target_len);
     501
     502        if (max == 0 || len <= max) {
    496503                return TRUE;
    497504        }
     
    867874}
    868875
     876bee_user_t twitter_log_local_user;
     877
    869878/** Convert the given bitlbee tweet ID, bitlbee username, or twitter tweet ID
    870879 *  into a twitter tweet ID.
     
    897906                        bu = td->log[id].bu;
    898907                        id = td->log[id].id;
    899                         /* Beware of dangling pointers! */
    900                         if (!g_slist_find(ic->bee->users, bu)) {
    901                                 bu = NULL;
    902                         }
    903908                } else if (twitter_parse_id(arg, 10, &id)) {
    904909                        /* Allow normal tweet IDs as well; not a very useful
     
    911916        }
    912917        if (bu_) {
     918                if (bu == &twitter_log_local_user) {
     919                        /* HACK alert. There's no bee_user object for the local
     920                         * user so just fake one for the few cmds that need it. */
     921                        twitter_log_local_user.handle = td->user;
     922                } else {
     923                        /* Beware of dangling pointers! */
     924                        if (!g_slist_find(ic->bee->users, bu)) {
     925                                bu = NULL;
     926                        }
     927                }
    913928                *bu_ = bu;
    914929        }
     
    10031018                in_reply_to = id;
    10041019                allow_post = TRUE;
     1020        } else if (g_strcasecmp(cmd[0], "url") == 0) {
     1021                id = twitter_message_id_from_command_arg(ic, cmd[1], &bu);
     1022                if (!id) {
     1023                        twitter_log(ic, "Tweet `%s' does not exist", cmd[1]);
     1024                } else {
     1025                        /* More common link is twitter.com/$UID/status/$ID (and that's
     1026                         * what this will 302 to) but can't generate that since for RTs,
     1027                         * bu here points at the retweeter while id contains the id of
     1028                         * the original message. */
     1029                        twitter_log(ic, "https://twitter.com/statuses/%lld", id);
     1030                }
     1031                goto eof;
     1032
    10051033        } else if (g_strcasecmp(cmd[0], "post") == 0) {
    10061034                message += 5;
Note: See TracChangeset for help on using the changeset viewer.