FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Coding-iOS/Coding_iOS/Models/PrivateMessage.m at master · refight/Coding-iOS · GitHub
refight
/
Coding-iOS
Public
forked from
coding/Coding-iOS
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Models
/
PrivateMessage.m
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
104 lines (95 loc) · 3.26 KB
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Models
/
PrivateMessage.m
Copy path
File metadata and controls
executable file
·
104 lines (95 loc) · 3.26 KB
Raw
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
94
95
96
97
98
99
100
101
102
103
104
//
//
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
);
}
- (
BOOL
)
isSingleBigMonkey
{
BOOL
isSingleBigMonkey =
NO
;
if
(self.
content
.
length
==
0
) {
if
(_htmlMedia.
imageItems
.
count
==
1
) {
HtmlMediaItem *item = [_htmlMedia.imageItems
firstObject
];
if
(item.
type
== HtmlMediaItemType_EmotionMonkey) {
isSingleBigMonkey =
YES
;
}
}
}
return
isSingleBigMonkey;
}
+ (
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
Back
|
FazBrowse Home
|
New Git URL