Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
93 lines (83 loc) · 2.89 KB

File metadata and controls

executable file
·
93 lines (83 loc) · 2.89 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// 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 && _htmlMedia.imageItems.count <= 0 && !_nextImg) {
_content = @" ";//占位
}else{
_content = _htmlMedia.contentDisplay;
}
}
}
- (BOOL)hasMedia{
return self.nextImg || (self.htmlMedia && self.htmlMedia.imageItems.count> 0);
}
+ (instancetype)privateMessageWithObj:(id)obj andFriend:(User *)curFriend{
PrivateMessage *nextMsg = [[PrivateMessage alloc] init];
nextMsg.sender = [Login curLoginUser];
nextMsg.friend = curFriend;
nextMsg.sendStatus = PrivateMessageStatusSending;
nextMsg.created_at = [NSDate date];
if ([obj isKindOfClass:[NSString class]]) {
nextMsg.content = obj;
nextMsg.extra = @"";
}else if ([obj isKindOfClass:[UIImage class]]){
nextMsg.nextImg = obj;
nextMsg.content = @"";
nextMsg.extra = @"";
}else if ([obj isKindOfClass:[VoiceMedia class]]){
nextMsg.voiceMedia = obj;
// nextMsg.content = @"";
nextMsg.extra = @"";
}else if ([obj isKindOfClass:[PrivateMessage class]]){
PrivateMessage *originalMsg = (PrivateMessage *)obj;
NSMutableString *content = [[NSMutableString alloc] initWithString:originalMsg.content];
NSMutableString *extra = [[NSMutableString alloc] init];
if (originalMsg.htmlMedia.mediaItems && originalMsg.htmlMedia.mediaItems.count > 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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.