adium 5263:6ce3247fff1c: As requested by drcross on IRC: when sp...

commits at adium.im commits at adium.im
Sun Jan 20 21:01:01 UTC 2013


details:	http://hg.adium.im/adium/rev/6ce3247fff1c
revision:	5263:6ce3247fff1c
branch:		adium-1.6
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Sun Jan 20 21:58:57 2013 +0100

As requested by drcross on IRC: when speaking a received message, don't read the full URL, just "link to example.com".

diffs (30 lines):

diff -r cc6d598f5692 -r 6ce3247fff1c Source/ESAnnouncerPlugin.m
--- a/Source/ESAnnouncerPlugin.m	Thu Jan 10 17:37:39 2013 -0500
+++ b/Source/ESAnnouncerPlugin.m	Sun Jan 20 21:58:57 2013 +0100
@@ -165,7 +165,25 @@
 			if ([adium.contactAlertsController isMessageEvent:eventID] &&
 				[userInfo objectForKey:@"AIContentObject"]) {
 				AIContentMessage	*content = [userInfo objectForKey:@"AIContentObject"];
-				message = [[[content message] attributedStringByConvertingAttachmentsToStrings] string];
+				NSMutableAttributedString *convertedMessage = [[[[content message] attributedStringByConvertingAttachmentsToStrings] mutableCopy] autorelease];
+				[convertedMessage enumerateAttribute:NSLinkAttributeName
+											 inRange:NSMakeRange(0, [convertedMessage length])
+											 options:0
+										  usingBlock:^(id value, NSRange range, BOOL *stop) {
+											  NSURL *url = nil;
+											  NSString *string = nil;
+											  if ([value isKindOfClass:[NSURL class]]) {
+												  url = value;
+												  string = [url absoluteString];
+											  } else if ([value isKindOfClass:[NSString class]]) {
+												  url = [NSURL URLWithString:value];
+												  string = value;
+											  }
+											  if ([string isEqualToString:[[convertedMessage string] substringWithRange:range]]) {
+												  [convertedMessage replaceCharactersInRange:range withString:[NSString stringWithFormat:AILocalizedString(@"link to %@", "replacement text for a link when reading a received message, %@ is the host"), [url host]]];
+											  }
+										  }];
+				message = [convertedMessage string];
 				
 			} else {
 				message = [adium.contactAlertsController naturalLanguageDescriptionForEventID:eventID




More information about the commits mailing list