diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2012-03-12 22:36:35 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2012-03-12 22:36:35 +0000 |
commit | d18dee42088f0bef9d09dbc7903590d755d19a50 (patch) | |
tree | e8c5d9b956e476420c990de825c061b103a008cd | |
parent | 57a656009b79afa0efc1fef360e6f7ca8a89ea01 (diff) |
Merging report-spam patch for Twitter from Flexo. #923
-rw-r--r-- | doc/user-guide/commands.xml | 1 | ||||
-rw-r--r-- | protocols/twitter/twitter.c | 19 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.c | 14 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.h | 4 |
4 files changed, 38 insertions, 0 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 20023d3a..d7635474 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -844,6 +844,7 @@ <varlistentry><term>undo #[<id>]</term><listitem><para>Delete your last Tweet (or one with the given ID)</para></listitem></varlistentry> <varlistentry><term>rt <screenname|#id></term><listitem><para>Retweet someone's last Tweet (or one with the given ID)</para></listitem></varlistentry> <varlistentry><term>reply <screenname|#id></term><listitem><para>Reply to a Tweet (with a reply-to reference)</para></listitem></varlistentry> + <varlistentry><term>report <screenname|#id></term><listitem><para>Report the given user (or the user who posted the tweet with the given ID) for sending spam. This will also block them.</para></listitem></varlistentry> <varlistentry><term>follow <screenname></term><listitem><para>Start following a person</para></listitem></varlistentry> <varlistentry><term>unfollow <screenname></term><listitem><para>Stop following a person</para></listitem></varlistentry> <varlistentry><term>post <message></term><listitem><para>Post a tweet</para></listitem></varlistentry> diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 1e404a02..6c294cae 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -529,6 +529,25 @@ static void twitter_handle_command(struct im_connection *ic, char *message) twitter_remove_buddy(ic, cmd[1], NULL); g_free(cmds); return; + } else if ((g_strcasecmp(cmd[0], "report") == 0 || + g_strcasecmp(cmd[0], "spam") == 0) && cmd[1]) { + char * screen_name; + guint64 id; + /* 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) { + 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; + } + } + } else { + screen_name = cmd[1]; + } + twitter_report_spam(ic, screen_name); + g_free(cmds); + return; } else if (g_strcasecmp(cmd[0], "rt") == 0 && cmd[1]) { struct twitter_user_data *tud; bee_user_t *bu; diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index 38964e66..bfcebd2b 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -1061,3 +1061,17 @@ void twitter_status_retweet(struct im_connection *ic, guint64 id) twitter_http(ic, url, twitter_http_post, ic, 1, NULL, 0); g_free(url); } + +/** + * Report a user for sending spam. + */ +void twitter_report_spam(struct im_connection *ic, char *screen_name) +{ + char *args[2] = { + "screen_name", + NULL, + }; + args[1] = screen_name; + twitter_http(ic, TWITTER_REPORT_SPAM_URL, twitter_http_post, + ic, 1, args, 2); +} diff --git a/protocols/twitter/twitter_lib.h b/protocols/twitter/twitter_lib.h index b06f5055..09b91e5b 100644 --- a/protocols/twitter/twitter_lib.h +++ b/protocols/twitter/twitter_lib.h @@ -75,6 +75,9 @@ #define TWITTER_BLOCKS_CREATE_URL "/blocks/create/" #define TWITTER_BLOCKS_DESTROY_URL "/blocks/destroy/" +/* Report spam */ +#define TWITTER_REPORT_SPAM_URL "/report_spam.xml" + void twitter_get_timeline(struct im_connection *ic, gint64 next_cursor); void twitter_get_friends_ids(struct im_connection *ic, gint64 next_cursor); void twitter_get_home_timeline(struct im_connection *ic, gint64 next_cursor); @@ -86,6 +89,7 @@ void twitter_direct_messages_new(struct im_connection *ic, char *who, char *mess void twitter_friendships_create_destroy(struct im_connection *ic, char *who, int create); void twitter_status_destroy(struct im_connection *ic, guint64 id); void twitter_status_retweet(struct im_connection *ic, guint64 id); +void twitter_report_spam(struct im_connection *ic, char *screen_name); #endif //_TWITTER_LIB_H |