[Adium-commits] adium 2051:88c5321bb510: Twitter now allows in_reply_to_status_i...
adium-commits at adiumx.com
adium-commits at adiumx.com
Fri May 1 17:07:30 UTC 2009
details: http://hg.adiumx.com/adium/rev/88c5321bb510
revision: 2051:88c5321bb510
author: Zachary West <zacw at adiumx.com>
date: Fri May 01 13:07:22 2009 -0400
Twitter now allows in_reply_to_status_id to reference _any_ mentioned user.
Only remove the in_reply_to_status_id values when the @username itself is removed, and insert the values for retweets, thus preserving the chain.
diffstat:
Plugins/Twitter Plugin/AITwitterAccount.m | 4 ++
Plugins/Twitter Plugin/AITwitterURLHandler.m | 38 ++++++-------------
2 files changed, 16 insertions(+), 26 deletions(-)
diffs (76 lines):
diff -r 0da4ed51dce3 -r 88c5321bb510 Plugins/Twitter Plugin/AITwitterAccount.m
--- a/Plugins/Twitter Plugin/AITwitterAccount.m Fri May 01 12:19:03 2009 -0400
+++ b/Plugins/Twitter Plugin/AITwitterAccount.m Fri May 01 13:07:22 2009 -0400
@@ -1373,6 +1373,10 @@
[mutableMessage appendAttributedString:[NSAttributedString attributedStringWithLinkLabel:@"@"
linkDestination:linkAddress]];
} else {
+ if(commaNeeded) {
+ [mutableMessage appendString:@", " withAttributes:nil];
+ }
+
// Our own message. Display a destroy link.
linkAddress = [self addressForLinkType:AITwitterLinkDestroyStatus
userID:userID
diff -r 0da4ed51dce3 -r 88c5321bb510 Plugins/Twitter Plugin/AITwitterURLHandler.m
--- a/Plugins/Twitter Plugin/AITwitterURLHandler.m Fri May 01 12:19:03 2009 -0400
+++ b/Plugins/Twitter Plugin/AITwitterURLHandler.m Fri May 01 13:07:22 2009 -0400
@@ -140,17 +140,15 @@
// Make the text view have focus
[[adium.interfaceController windowForChat:timelineChat] makeFirstResponder:textView];
- if([inAction isEqualToString:@"reply"]) {
- [timelineChat setValue:inTweet forProperty:@"TweetInReplyToStatusID" notify:NotifyNow];
- [timelineChat setValue:inUser forProperty:@"TweetInReplyToUserID" notify:NotifyNow];
- [timelineChat setValue:@"@" forProperty:@"Character Counter Prefix" notify:NotifyNow];
-
- AILogWithSignature(@"Flagging chat %@ to in_reply_to_status_id = %@", timelineChat, inTweet);
-
- [[NSNotificationCenter defaultCenter] removeObserver:self name:NSTextDidChangeNotification object:textView];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:NSTextDidChangeNotification object:textView];
- }
+ [timelineChat setValue:inTweet forProperty:@"TweetInReplyToStatusID" notify:NotifyNow];
+ [timelineChat setValue:inUser forProperty:@"TweetInReplyToUserID" notify:NotifyNow];
+ [timelineChat setValue:@"@" forProperty:@"Character Counter Prefix" notify:NotifyNow];
+
+ AILogWithSignature(@"Flagging chat %@ to in_reply_to_status_id = %@", timelineChat, inTweet);
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSTextDidChangeNotification object:textView];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:NSTextDidChangeNotification object:textView];
} else if ([inAction isEqualToString:@"favorite"]) {
[account toggleFavoriteTweet:inTweet];
} else if ([inAction isEqualToString:@"destroy"] && exactMatchForInternalID) {
@@ -179,7 +177,6 @@
AIMessageEntryTextView *textView = [notification object];
AIChat *chat = textView.chat;
- AIAccount *account = chat.account;
if(![chat valueForProperty:@"TweetInReplyToStatusID"] || ![chat valueForProperty:@"TweetInReplyToUserID"]) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSTextDidChangeNotification object:textView];
@@ -189,20 +186,9 @@
NSString *contents = [textView string];
BOOL keepTweetValues = YES;
- if([contents hasPrefix:@"@"]) {
- NSString *replyUsername = [contents substringFromIndex:1];
- NSRange usernameRange = [replyUsername rangeOfCharacterFromSet:[account.service.allowedCharacters invertedSet]];
-
- if(usernameRange.location == NSNotFound) {
- usernameRange = NSMakeRange([replyUsername length], 0);
- }
-
- replyUsername = [replyUsername substringToIndex:usernameRange.location];
-
- if (![replyUsername isEqualToString:[chat valueForProperty:@"TweetInReplyToUserID"]]) {
- keepTweetValues = NO;
- }
- } else {
+ NSRange usernameRange = [contents rangeOfString:[NSString stringWithFormat:@"@%@", [chat valueForProperty:@"TweetInReplyToUserID"]]];
+
+ if (usernameRange.location == NSNotFound) {
keepTweetValues = NO;
}
More information about the commits
mailing list