Mailer: remove HTML from list of messages in JSON

pull/91/head
Francis Lachapelle 2014-11-21 15:44:19 -05:00
parent e5ce053a62
commit bd9da51e83
3 changed files with 24 additions and 112 deletions

View File

@ -1,20 +1,21 @@
/*
Copyright (C) 2004-2005 SKYRIX Software AG
Copyright (C) 2004-2014 Inverse inc
This file is part of OpenGroupware.org.
This file is part of SOGo.
OGo is free software; you can redistribute it and/or modify it under
SOGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with OGo; see the file COPYING. If not, write to the
License along with SOGo; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
@ -43,10 +44,8 @@
}
- (NSString *) defaultSortKey;
- (NSString *) imap4SortKey;
- (NSString *) imap4SortOrdering;
- (EOQualifier *) searchQualifier;
- (NSString *) msgLabels;
- (NSArray *) getSortedUIDsInFolder: (SOGoMailFolder *) mailFolder;
- (NSArray *) getHeadersForUIDs: (NSArray *) uids

View File

@ -15,7 +15,7 @@
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with OGo; see the file COPYING. If not, write to the
License along with SOGo; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
@ -186,7 +186,7 @@
if (![subject length])
subject = @"";
return [[subject safeString] stringByEscapingHTMLString];
return subject;
}
- (BOOL) showToAddress
@ -254,34 +254,6 @@
return [[[self message] valueForKey:@"uid"] stringValue];
}
- (NSString *) messageRowStyleClass
{
NSArray *flags;
NSString *cellClass = @"";
flags = [[self message] valueForKey:@"flags"];
if ([self isMessageDeleted])
cellClass = [cellClass stringByAppendingString: @"mailer_listcell_deleted "];
if (![self isMessageRead])
cellClass = [cellClass stringByAppendingString: @"mailer_unreadmail "];
if ([flags containsObject: @"answered"])
{
if ([flags containsObject: @"$forwarded"])
cellClass = [cellClass stringByAppendingString: @"mailer_forwardedrepliedmailsubject"];
else
cellClass = [cellClass stringByAppendingString: @"mailer_repliedmailsubject"];
}
else if ([flags containsObject: @"$forwarded"])
cellClass = [cellClass stringByAppendingString: @"mailer_forwardedmailsubject"];
else
cellClass = [cellClass stringByAppendingString: @"mailer_readmailsubject"];
return cellClass;
}
- (BOOL) hasMessageAttachment
{
NSArray *parts;
@ -462,8 +434,7 @@
}
/**
* Returns a
of the messages threads as triples of
* Returns the messages threads as triples of
* metadata, including the message UID, thread level and root position.
* @param _sortedUIDs the interleaved arrays representation of the messages UIDs
* @return an flatten array representation of the messages UIDs
@ -576,23 +547,6 @@
return index;
}
/* JavaScript */
- (NSString *) msgRowID
{
return [@"row_" stringByAppendingString:[self messageUidString]];
}
- (NSString *) msgIconReadImgID
{
return [@"readdiv_" stringByAppendingString:[self messageUidString]];
}
- (NSString *) msgIconUnreadImgID
{
return [@"unreaddiv_" stringByAppendingString:[self messageUidString]];
}
/* error redirects */
/*
@ -688,8 +642,8 @@
response = [context response];
requestContent = [[request contentAsString] objectFromJSONString];
[response setHeader: @"text/plain; charset=utf-8"
forKey: @"content-type"];
[response setHeader: @"application/json; charset=utf-8"
forKey: @"content-type"];
folder = [self clientObject];
@ -709,7 +663,7 @@
NSDictionary *msgs;
NSMutableArray *headers, *msg;
NSEnumerator *msgsList;
NSString *msgIconStatus, *msgDate;
NSString *msgDate;
UIxEnvelopeAddressFormatter *addressFormatter;
headers = [NSMutableArray arrayWithCapacity: [uids count]];
@ -722,7 +676,7 @@
msgsList = [[msgs objectForKey: @"fetch"] objectEnumerator];
[self setMessage: [msgsList nextObject]];
msg = [NSMutableArray arrayWithObjects: @"To", @"Attachment", @"Flagged", @"Subject", @"From", @"Unread", @"Priority", @"Date", @"Size", @"rowClasses", @"labels", @"rowID", @"uid", nil];
msg = [NSMutableArray arrayWithObjects: @"To", @"hasAttachment", @"isFlagged", @"Subject", @"From", @"isRead", @"Priority", @"Date", @"Size", @"Flags", @"uid", nil];
[headers addObject: msg];
while (message)
{
@ -757,23 +711,14 @@
else
[msg addObject: @""];
// Attachment
if ([self hasMessageAttachment])
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\"/>", [self urlForResourceFilename: @"title_attachment_14x14.png"]]];
else
[msg addObject: @""];
// hasAttachment
[msg addObject: [NSNumber numberWithBool: [self hasMessageAttachment]]];
// Flagged
if ([self isMessageFlagged])
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\" class=\"messageIsFlagged\">",
[self urlForResourceFilename: @"flag.png"]]];
else
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\">",
[self urlForResourceFilename: @"dot.png"]]];
// isFlagged
[msg addObject: [NSNumber numberWithBool: [self isMessageFlagged]]];
// Subject
[msg addObject: [NSString stringWithFormat: @"<span>%@</span>",
[self messageSubject]]];
[msg addObject: [self messageSubject]];
// From
from = [[message objectForKey: @"envelope"] from];
@ -783,18 +728,8 @@
[msg addObject: @""];
// Unread
if ([self isMessageRead])
msgIconStatus = @"dot.png";
else
msgIconStatus = @"unread.png";
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\" class=\"mailerReadIcon\" title=\"%@\" title-markread=\"%@\" title-markunread=\"%@\" id=\"%@\"/>",
[self urlForResourceFilename: msgIconStatus],
[self labelForKey: @"Mark Unread"],
[self labelForKey: @"Mark Read"],
[self labelForKey: @"Mark Unread"],
[self msgIconReadImgID]]];
// isRead
[msg addObject: [NSNumber numberWithBool: [self isMessageRead]]];
// Priority
[msg addObject: [self messagePriority]];
@ -807,15 +742,9 @@
// Size
[msg addObject: [[self sizeFormatter] stringForObjectValue: [message objectForKey: @"size"]]];
// rowClasses
[msg addObject: [self messageRowStyleClass]];
// labels
[msg addObject: [self msgLabels]];
// rowID
[msg addObject: [self msgRowID]];
[msg addObject: [message objectForKey: @"flags"]];
// uid
[msg addObject: [message objectForKey: @"uid"]];
@ -844,30 +773,13 @@
headers = [self getHeadersForUIDs: uids
inFolder: [self clientObject]];
response = [context response];
[response setHeader: @"text/plain; charset=utf-8"
[response setHeader: @"application/json; charset=utf-8"
forKey: @"content-type"];
[response appendContentString: [headers jsonRepresentation]];
return response;
}
- (NSString *) msgLabels
{
NSMutableArray *labels;
NSEnumerator *flags;
NSString *currentFlag;
labels = [NSMutableArray array];
flags = [[message objectForKey: @"flags"] objectEnumerator];
while ((currentFlag = [flags nextObject]))
{
[labels addObject: currentFlag];
}
return [labels componentsJoinedByString: @" "];
}
@end
/* UIxMailListActions */

View File

@ -77,7 +77,7 @@
};
};
methods = {
uids = {
view = {
protectedBy = "<public>";
actionClass = "UIxMailListActions";
actionName = "getUIDs";
@ -222,6 +222,7 @@
view = {
protectedBy = "View";
pageName = "UIxMailView";
actionName = "default";
};
sendMDN = {
protectedBy = "View";
@ -352,7 +353,7 @@
actionClass = "UIxMailAccountActions";
actionName = "compose";
};
mailboxes = {
view = {
protectedBy = "View";
actionClass = "UIxMailAccountActions";
actionName = "listMailboxes";