adium 4352:99aaf53dc82b: When a tweet is a retweet and contains ...
commits at adium.im
commits at adium.im
Tue Dec 6 17:09:14 UTC 2011
details: http://hg.adium.im/adium/rev/99aaf53dc82b
revision: 4352:99aaf53dc82b
branch: (none)
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Tue Dec 06 18:08:36 2011 +0100
When a tweet is a retweet and contains its original, use the original text instead, prepended with "RT @user: ".
Fixes #15226
diffs (75 lines):
diff -r cabe83e56b8d -r 99aaf53dc82b Plugins/Twitter Plugin/AITwitterAccount.h
--- a/Plugins/Twitter Plugin/AITwitterAccount.h Mon Dec 05 22:52:41 2011 +0200
+++ b/Plugins/Twitter Plugin/AITwitterAccount.h Tue Dec 06 18:08:36 2011 +0100
@@ -118,6 +118,7 @@
#define TWITTER_STATUS_USER @"user"
#define TWITTER_STATUS_UID @"screen_name"
#define TWITTER_STATUS_TEXT @"text"
+#define TWITTER_STATUS_RETWEET @"retweeted_status"
// Direct Messages
#define TWITTER_DM_ID @"id"
diff -r cabe83e56b8d -r 99aaf53dc82b Plugins/Twitter Plugin/AITwitterAccount.m
--- a/Plugins/Twitter Plugin/AITwitterAccount.m Mon Dec 05 22:52:41 2011 +0200
+++ b/Plugins/Twitter Plugin/AITwitterAccount.m Tue Dec 06 18:08:36 2011 +0100
@@ -1724,8 +1724,16 @@
[[AIContactObserverManager sharedManager] delayListObjectNotifications];
for (NSDictionary *status in sortedQueuedUpdates) {
+ NSDictionary *retweet = [status objectForKey:TWITTER_STATUS_RETWEET];
+ NSString *text = [status objectForKey:TWITTER_STATUS_TEXT];
+
+ if (retweet && [retweet isKindOfClass:[NSDictionary class]]) {
+ text = [NSString stringWithFormat:@"RT @%@: %@",
+ [[retweet objectForKey:TWITTER_STATUS_USER] objectForKey:TWITTER_STATUS_UID],
+ [retweet objectForKey:TWITTER_STATUS_TEXT]];
+ }
+
NSDate *date = [status objectForKey:TWITTER_STATUS_CREATED];
- NSString *text = [status objectForKey:TWITTER_STATUS_TEXT];
NSString *contactUID = [[status objectForKey:TWITTER_STATUS_USER] objectForKey:TWITTER_STATUS_UID];
@@ -2183,11 +2191,21 @@
AILogWithSignature(@"%@ Updating statuses for profile, user %@", self, listContact);
for (NSDictionary *update in statuses) {
- NSAttributedString *message = [self parseMessage:[update objectForKey:TWITTER_STATUS_TEXT]
- tweetID:[update objectForKey:TWITTER_STATUS_ID]
- userID:listContact.UID
- inReplyToUser:[update objectForKey:TWITTER_STATUS_REPLY_UID]
- inReplyToTweetID:[update objectForKey:TWITTER_STATUS_REPLY_ID]];
+ NSAttributedString *message;
+ NSDictionary *retweet = [update valueForKey:TWITTER_STATUS_RETWEET];
+ NSString *text = [update objectForKey:TWITTER_STATUS_TEXT];
+
+ if (retweet && [retweet isKindOfClass:[NSDictionary class]]) {
+ text = [NSString stringWithFormat:@"RT @%@: %@",
+ [[retweet objectForKey:TWITTER_STATUS_USER] objectForKey:TWITTER_STATUS_UID],
+ [retweet objectForKey:TWITTER_STATUS_TEXT]];
+ }
+
+ message = [self parseMessage:text
+ tweetID:[update objectForKey:TWITTER_STATUS_ID]
+ userID:listContact.UID
+ inReplyToUser:[update objectForKey:TWITTER_STATUS_REPLY_UID]
+ inReplyToTweetID:[update objectForKey:TWITTER_STATUS_REPLY_ID]];
[profileArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:message, KEY_VALUE, nil]];
}
@@ -2209,7 +2227,14 @@
object:update
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:self.timelineChat, @"AIChat", nil]];
- NSString *text = [[update objectForKey:TWITTER_STATUS_TEXT] stringByUnescapingFromXMLWithEntities:nil];
+ NSDictionary *retweet = [update valueForKey:TWITTER_STATUS_RETWEET];
+ NSString *text = [[update objectForKey:TWITTER_STATUS_TEXT] stringByEscapingForXMLWithEntities:nil];
+
+ if (retweet && [retweet isKindOfClass:[NSDictionary class]]) {
+ text = [[NSString stringWithFormat:@"RT @%@: %@",
+ [[retweet objectForKey:TWITTER_STATUS_USER] objectForKey:TWITTER_STATUS_UID],
+ [retweet objectForKey:TWITTER_STATUS_TEXT]] stringByEscapingForXMLWithEntities:nil];
+ }
if([[self preferenceForKey:TWITTER_PREFERENCE_UPDATE_GLOBAL group:TWITTER_PREFERENCE_GROUP_UPDATES] boolValue] &&
(![text hasPrefix:@"@"] || [[self preferenceForKey:TWITTER_PREFERENCE_UPDATE_GLOBAL_REPLIES group:TWITTER_PREFERENCE_GROUP_UPDATES] boolValue])) {
More information about the commits
mailing list