-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmessage.go
More file actions
190 lines (162 loc) · 6.69 KB
/
Copy pathmessage.go
File metadata and controls
190 lines (162 loc) · 6.69 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package juggleimsdk
import "net/http"
type Message struct {
SenderId string `json:"sender_id"`
TargetId string `json:"target_id"`
ReceiverId string `json:"receiver_id"`
TargetIds []string `json:"target_ids"`
ToUserIds []string `json:"to_user_ids"`
MsgType string `json:"msg_type"`
MsgContent string `json:"msg_content"`
LifeTime int64 `json:"life_time"`
LifeTimeAfterRead int64 `json:"life_time_after_read"`
IsStorage *bool `json:"is_storage"`
IsCount *bool `json:"is_count"`
IsNotifySender *bool `json:"is_notify_sender"`
IsState *bool `json:"is_state"`
IsCmd *bool `json:"is_cmd"`
MentionInfo *MentionInfo `json:"mention_info,omitempty"`
ReferMsg *ReferMsg `json:"refer_msg,omitempty"`
PushData *PushData `json:"push_data,omitempty"`
MsgId *string `json:"msg_id,omitempty"`
}
type MentionType string
const (
MentionType_All MentionType = "mention_all"
MentionType_Someone MentionType = "mention_someone"
MentionType_AllSomeone MentionType = "mention_all_someone"
)
type MentionInfo struct {
MentionType MentionType `json:"mention_type"`
TargetUsers []*User `json:"target_users"`
TargetUserIds []string `json:"target_user_ids"`
}
type ReferMsg struct {
MsgId string `json:"msg_id"`
SenderId string `json:"sender_id"`
TargetId string `json:"target_id"`
ChannelType int `json:"channel_type"`
MsgType string `json:"msg_type"`
MsgTime int64 `json:"msg_time"`
MsgContent string `json:"msg_content"`
}
type PushData struct {
PushTitle string `json:"push_title"`
PushText string `json:"push_text"`
PushExtra string `json:"push_extra"`
PushLevel int `json:"push_level"`
}
func (sdk *JuggleIMSdk) SendPrivateMsg(msg Message) (ApiCode, string, error) {
urlPath := "/apigateway/messages/private/send"
return sdk.HttpCall(http.MethodPost, urlPath, msg, nil)
}
func (sdk *JuggleIMSdk) SendSystemMsg(msg Message) (ApiCode, string, error) {
urlPath := "/apigateway/messages/system/send"
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, msg, nil)
return code, traceId, err
}
func (sdk *JuggleIMSdk) SendGroupMsg(msg Message) (ApiCode, string, error) {
urlPath := "/apigateway/messages/group/send"
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, msg, nil)
return code, traceId, err
}
func (sdk *JuggleIMSdk) SendChatroomMsg(msg Message) (ApiCode, string, error) {
urlPath := "/apigateway/messages/chatroom/send"
return sdk.HttpCall(http.MethodPost, urlPath, msg, nil)
}
func (sdk *JuggleIMSdk) SendChatroomBrdMsg(msg Message) (ApiCode, string, error) {
urlPath := "/apigateway/messages/chatroom/broadcast"
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, msg, nil)
return code, traceId, err
}
type TargetConver struct {
TargetId string `json:"target_id"`
ChannelType int `json:"channel_type"`
}
type SendGrpCastMsgReq struct {
SenderId string `json:"sender_id"`
TargetId string `json:"target_id"`
MsgType string `json:"msg_type"`
MsgContent string `json:"msg_content"`
TargetConvers []*TargetConver `json:"target_convers"`
}
func (sdk *JuggleIMSdk) SendGroupCastMsg(req SendGrpCastMsgReq) (ApiCode, string, error) {
urlPath := "/apigateway/messages/groupcast/send"
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, req, nil)
return code, traceId, err
}
type SendBrdCastMsgReq struct {
SenderId string `json:"sender_id"`
MsgType string `json:"msg_type"`
MsgContent string `json:"msg_content"`
IsStorage *bool `json:"is_storage"`
}
func (sdk *JuggleIMSdk) SendBroadCastMsg(req SendBrdCastMsgReq) (ApiCode, string, error) {
urlPath := "/apigateway/messages/broadcast/send"
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, req, nil)
return code, traceId, err
}
func (sdk *JuggleIMSdk) SendPublicChannelMsg(msg Message) (ApiCode, string, error) {
urlPath := "/apigateway/messages/publicchannel/send"
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, msg, nil)
return code, traceId, err
}
type MarkReadReq struct {
UserId string `json:"user_id"`
TargetId string `json:"target_id"`
ChannelType int32 `json:"channel_type"`
MsgIds []string `json:"msg_ids"`
}
func (sdk *JuggleIMSdk) MarkRead(req MarkReadReq) (ApiCode, string, error) {
urlPath := "/apigateway/messages/markread"
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, req, nil)
return code, traceId, err
}
type StreamMsg struct {
MsgId string `json:"msg_id"`
FromId string `json:"from_id"`
TargetId string `json:"target_id"`
PartialContent string `json:"partial_content"`
Seq int `json:"seq"`
IsFinished bool `json:"is_finished"`
}
type SendMsgRespItem struct {
TargetId string `json:"target_id,omitempty"`
MsgId string `json:"msg_id"`
}
func (sdk *JuggleIMSdk) SendPrivateStreamMsg(msg StreamMsg) (*SendMsgRespItem, ApiCode, string, error) {
urlPath := "/apigateway/messages/private/stream/send"
resp := &SendMsgRespItem{}
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, msg, resp)
return resp, code, traceId, err
}
func (sdk *JuggleIMSdk) SendPrivateMsgWithResp(msg Message) ([]*SendMsgRespItem, ApiCode, string, error) {
urlPath := "/apigateway/messages/private/send"
var resp []*SendMsgRespItem
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, msg, &resp)
return resp, code, traceId, err
}
func (sdk *JuggleIMSdk) SendSystemMsgWithResp(msg Message) ([]*SendMsgRespItem, ApiCode, string, error) {
urlPath := "/apigateway/messages/system/send"
var resp []*SendMsgRespItem
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, msg, &resp)
return resp, code, traceId, err
}
func (sdk *JuggleIMSdk) SendGroupMsgWithResp(msg Message) ([]*SendMsgRespItem, ApiCode, string, error) {
urlPath := "/apigateway/messages/group/send"
var resp []*SendMsgRespItem
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, msg, &resp)
return resp, code, traceId, err
}
func (sdk *JuggleIMSdk) SendChatroomMsgWithResp(msg Message) ([]*SendMsgRespItem, ApiCode, string, error) {
urlPath := "/apigateway/messages/chatroom/send"
var resp []*SendMsgRespItem
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, msg, &resp)
return resp, code, traceId, err
}
func (sdk *JuggleIMSdk) SendPublicChannelMsgWithResp(msg Message) ([]*SendMsgRespItem, ApiCode, string, error) {
urlPath := "/apigateway/messages/publicchannel/send"
var resp []*SendMsgRespItem
code, traceId, err := sdk.HttpCall(http.MethodPost, urlPath, msg, &resp)
return resp, code, traceId, err
}