-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathsys_message.py
More file actions
87 lines (67 loc) · 1.81 KB
/
Copy pathsys_message.py
File metadata and controls
87 lines (67 loc) · 1.81 KB
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
# coding: utf-8
"""
实时通讯会话相关操作。
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import arrow
from leancloud.object_ import Object
class SysMessage(Object):
@property
def conversation(self):
"""
此消息对应的对话,对应 conv 字段。
:rtype: leancloud.Conversation
"""
return self.get("conv")
@property
def message_id(self):
"""
此消息 id,对应 msgId 字段。
:rtype: str
"""
return self.get("msgId")
@property
def is_binary(self):
"""
此消息内容是否为二进制,对应 bin 字段。
:rtype: bool
"""
return self.get("bin")
@property
def from_client(self):
"""
此消息发送者 cliend id,对应 client 字段。
:rtype: str
"""
return self.get("from")
@property
def from_ip(self):
"""
此消息发送者 IP,对应 fromIp 字段。
:rtype: str
"""
return self.get("fromIp")
@property
def data(self):
"""
此消息原始内容,如果需要的话,需要手动进行序列化,对应 data 字段。
:rtype: str
"""
return self.get("data")
@property
def message_created_at(self):
"""
此消息发送时间,对应 timestamp 字段。
:rtype: datetime
"""
return arrow.get(self.get("timestamp") / 1000).to("local").datetime
@property
def ack_at(self):
"""
此消息送达时间,对应 ackAt 字段。
:rtype: datetime
"""
return arrow.get(self.get("ackAt") / 1000).to("local").datetime