adium-1.4 2795:ffdf2878fc68: Hackify the retweet support to deal...
commits at adium.im
commits at adium.im
Mon Nov 23 04:27:14 UTC 2009
details: http://hg.adium.im/adium-1.4/rev/ffdf2878fc68
revision: 2795:ffdf2878fc68
author: Zachary West <zacw at adium.im>
date: Sun Nov 22 23:26:55 2009 -0500
Hackify the retweet support to deal with Laconica not supporting /api/statuses/retweet/%d.xml yet by falling back on inserting it in the text field.
diffs (88 lines):
diff -r 592152c93c30 -r ffdf2878fc68 Plugins/Twitter Plugin/AILaconicaAccount.m
--- a/Plugins/Twitter Plugin/AILaconicaAccount.m Sun Nov 22 23:19:26 2009 -0500
+++ b/Plugins/Twitter Plugin/AILaconicaAccount.m Sun Nov 22 23:26:55 2009 -0500
@@ -167,4 +167,19 @@
return attributedString;
}
+/*!
+ * @brief Retweet the selected tweet.
+ *
+ * Attempts to retweet a tweet.
+ * Prints a status message in the chat on success/failure, behaves identical to sending a new tweet.
+ *
+ * @returns YES if the account could send a retweet message, NO if the account doesn't support it.
+ *
+ * XXX When Laconica officially supports a retweet API, remove this method entirely.
+ */
+- (BOOL)retweetTweet:(NSString *)tweetID
+{
+ return NO;
+}
+
@end
diff -r 592152c93c30 -r ffdf2878fc68 Plugins/Twitter Plugin/AITwitterAccount.h
--- a/Plugins/Twitter Plugin/AITwitterAccount.h Sun Nov 22 23:19:26 2009 -0500
+++ b/Plugins/Twitter Plugin/AITwitterAccount.h Sun Nov 22 23:26:55 2009 -0500
@@ -182,7 +182,7 @@
location:(NSString *)location
description:(NSString *)description;
-- (void)retweetTweet:(NSString *)tweetID;
+- (BOOL)retweetTweet:(NSString *)tweetID;
- (void)toggleFavoriteTweet:(NSString *)tweetID;
- (void)destroyTweet:(NSString *)tweetID;
- (void)destroyDirectMessage:(NSString *)messageID
diff -r 592152c93c30 -r ffdf2878fc68 Plugins/Twitter Plugin/AITwitterAccount.m
--- a/Plugins/Twitter Plugin/AITwitterAccount.m Sun Nov 22 23:19:26 2009 -0500
+++ b/Plugins/Twitter Plugin/AITwitterAccount.m Sun Nov 22 23:26:55 2009 -0500
@@ -1199,8 +1199,10 @@
*
* Attempts to retweet a tweet.
* Prints a status message in the chat on success/failure, behaves identical to sending a new tweet.
+ *
+ * @returns YES if the account could send a retweet message, NO if the account doesn't support it.
*/
-- (void)retweetTweet:(NSString *)tweetID
+- (BOOL)retweetTweet:(NSString *)tweetID
{
NSString *requestID = [twitterEngine retweetUpdate:tweetID];
@@ -1211,6 +1213,8 @@
} else {
[self.timelineChat receivedError:[NSNumber numberWithInt:AIChatMessageSendingConnectionError]];
}
+
+ return YES;
}
/*!
diff -r 592152c93c30 -r ffdf2878fc68 Plugins/Twitter Plugin/AITwitterURLHandler.m
--- a/Plugins/Twitter Plugin/AITwitterURLHandler.m Sun Nov 22 23:19:26 2009 -0500
+++ b/Plugins/Twitter Plugin/AITwitterURLHandler.m Sun Nov 22 23:26:55 2009 -0500
@@ -104,9 +104,13 @@
return;
}
- if ([inAction isEqualToString:@"retweet"]) {
- [account retweetTweet:inTweet];
- } else if ([inAction isEqualToString:@"reply"]) {
+ BOOL retweetAsReply = NO;
+
+ if ([inAction isEqualToString:@"retweet"]) {
+ retweetAsReply = ![account retweetTweet:inTweet];
+ }
+
+ if (retweetAsReply || [inAction isEqualToString:@"reply"]) {
AIChat *timelineChat = [adium.chatController existingChatWithName:account.timelineChatName
onAccount:account];
@@ -127,7 +131,7 @@
AIMessageEntryTextView *textView = ((AIMessageTabViewItem *)[timelineChat valueForProperty:@"MessageTabViewItem"]).messageViewController.textEntryView;
// Insert the @reply text
- NSString *prefix = [NSString stringWithFormat:@"@%@ ", inUser];
+ NSString *prefix = retweetAsReply ? [NSString stringWithFormat:@"RT @%@: %@", inUser, [inMessage stringByDecodingURLEscapes]] : [NSString stringWithFormat:@"@%@ ", inUser];
if (![textView.string hasPrefix:prefix]) {
NSMutableAttributedString *newString;
More information about the commits
mailing list