//
// PrivateMessage.m
// Coding_iOS
//
// Created by on 14-8-29.
// Copyright (c) 2014 Coding. All rights reserved.
//
#import "PrivateMessage.h"
#import "Login.h"
@implementation PrivateMessage
- (instancetype)init
{
self = [super init];
if (self) {
_sendStatus = PrivateMessageStatusSendSucess;
_id = @(-1);
}
return self;
}
- (void)setContent:(NSString *)content{
if (_content != content) {
_htmlMedia = [HtmlMedia htmlMediaWithString:content showType:MediaShowTypeCode];
if (_htmlMedia.contentDisplay.length 0) {
for (HtmlMediaItem *item in originalMsg.htmlMedia.mediaItems) {
if (item.type == HtmlMediaItemType_Image) {
if (extra.length > 0) {
[extra appendFormat:@",%@", item.src];
}else{
[extra appendString:item.src];
}
}else if (item.type == HtmlMediaItemType_EmotionMonkey){
[content appendFormat:@" :%@: ", item.title];
}
}
}
nextMsg.content = content;
nextMsg.extra = extra;
}
return nextMsg;
};
- (NSString *)toSendPath{
return @"api/message/send";
}
- (NSDictionary *)toSendParams{
return @{@"content" : _content? [_content aliasedString]: @"",
@"extra" : _extra? _extra: @"",
@"receiver_global_key" : _friend.global_key};
}
- (NSString *)toDeletePath{
return [NSString stringWithFormat:@"api/message/%ld", _id.longValue];
}
@end