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.
authorZachary West <zacw@adium.im>
Sun Nov 22 23:26:55 2009 -0500 (2009-11-22)
changeset 2795ffdf2878fc68
parent 2794 592152c93c30
child 2796 7ffe6bd0f0d7
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.
Plugins/Twitter Plugin/AILaconicaAccount.m
Plugins/Twitter Plugin/AITwitterAccount.h
Plugins/Twitter Plugin/AITwitterAccount.m
Plugins/Twitter Plugin/AITwitterURLHandler.m
     1.1 --- a/Plugins/Twitter Plugin/AILaconicaAccount.m	Sun Nov 22 23:19:26 2009 -0500
     1.2 +++ b/Plugins/Twitter Plugin/AILaconicaAccount.m	Sun Nov 22 23:26:55 2009 -0500
     1.3 @@ -167,4 +167,19 @@
     1.4  	return attributedString;
     1.5  }
     1.6  
     1.7 +/*!
     1.8 + * @brief Retweet the selected tweet.
     1.9 + *
    1.10 + * Attempts to retweet a tweet.
    1.11 + * Prints a status message in the chat on success/failure, behaves identical to sending a new tweet.
    1.12 + *
    1.13 + * @returns YES if the account could send a retweet message, NO if the account doesn't support it.
    1.14 + *
    1.15 + * XXX When Laconica officially supports a retweet API, remove this method entirely.
    1.16 + */
    1.17 +- (BOOL)retweetTweet:(NSString *)tweetID
    1.18 +{
    1.19 +	return NO;
    1.20 +}
    1.21 +
    1.22  @end
     2.1 --- a/Plugins/Twitter Plugin/AITwitterAccount.h	Sun Nov 22 23:19:26 2009 -0500
     2.2 +++ b/Plugins/Twitter Plugin/AITwitterAccount.h	Sun Nov 22 23:26:55 2009 -0500
     2.3 @@ -182,7 +182,7 @@
     2.4  			  location:(NSString *)location
     2.5  		   description:(NSString *)description;
     2.6  
     2.7 -- (void)retweetTweet:(NSString *)tweetID;
     2.8 +- (BOOL)retweetTweet:(NSString *)tweetID;
     2.9  - (void)toggleFavoriteTweet:(NSString *)tweetID;
    2.10  - (void)destroyTweet:(NSString *)tweetID;
    2.11  - (void)destroyDirectMessage:(NSString *)messageID
     3.1 --- a/Plugins/Twitter Plugin/AITwitterAccount.m	Sun Nov 22 23:19:26 2009 -0500
     3.2 +++ b/Plugins/Twitter Plugin/AITwitterAccount.m	Sun Nov 22 23:26:55 2009 -0500
     3.3 @@ -1199,8 +1199,10 @@
     3.4   *
     3.5   * Attempts to retweet a tweet.
     3.6   * Prints a status message in the chat on success/failure, behaves identical to sending a new tweet.
     3.7 + *
     3.8 + * @returns YES if the account could send a retweet message, NO if the account doesn't support it.
     3.9   */
    3.10 -- (void)retweetTweet:(NSString *)tweetID
    3.11 +- (BOOL)retweetTweet:(NSString *)tweetID
    3.12  {
    3.13  	NSString *requestID = [twitterEngine retweetUpdate:tweetID];
    3.14  	
    3.15 @@ -1211,6 +1213,8 @@
    3.16  	} else {
    3.17  		[self.timelineChat receivedError:[NSNumber numberWithInt:AIChatMessageSendingConnectionError]];
    3.18  	}
    3.19 +	
    3.20 +	return YES;
    3.21  }
    3.22  
    3.23  /*!
     4.1 --- a/Plugins/Twitter Plugin/AITwitterURLHandler.m	Sun Nov 22 23:19:26 2009 -0500
     4.2 +++ b/Plugins/Twitter Plugin/AITwitterURLHandler.m	Sun Nov 22 23:26:55 2009 -0500
     4.3 @@ -104,9 +104,13 @@
     4.4  		return;
     4.5  	}
     4.6  	
     4.7 -	if ([inAction isEqualToString:@"retweet"]) {
     4.8 -		[account retweetTweet:inTweet];
     4.9 -	} else if ([inAction isEqualToString:@"reply"]) {
    4.10 +	BOOL retweetAsReply = NO;
    4.11 +	
    4.12 +	if ([inAction isEqualToString:@"retweet"]) {	
    4.13 +		retweetAsReply = ![account retweetTweet:inTweet];
    4.14 +	}
    4.15 +	
    4.16 +	if (retweetAsReply || [inAction isEqualToString:@"reply"]) {
    4.17  		AIChat *timelineChat = [adium.chatController existingChatWithName:account.timelineChatName
    4.18  																onAccount:account];
    4.19  		
    4.20 @@ -127,7 +131,7 @@
    4.21  		AIMessageEntryTextView *textView = ((AIMessageTabViewItem *)[timelineChat valueForProperty:@"MessageTabViewItem"]).messageViewController.textEntryView;
    4.22  
    4.23  		// Insert the @reply text
    4.24 -		NSString *prefix = [NSString stringWithFormat:@"@%@ ", inUser];
    4.25 +		NSString *prefix = retweetAsReply ? [NSString stringWithFormat:@"RT @%@: %@", inUser, [inMessage stringByDecodingURLEscapes]] : [NSString stringWithFormat:@"@%@ ", inUser];
    4.26  		
    4.27  		if (![textView.string hasPrefix:prefix]) {
    4.28  			NSMutableAttributedString *newString;