forked from GetStream/stream-chat-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream_chat.go
112 lines (98 loc) · 4.38 KB
/
stream_chat.go
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
//go:generate go run github.com/getstream/easyjson/easyjson -pkg -all
// Package stream_chat provides chat via stream API
package stream_chat // nolint: golint
import (
"time"
)
// for interfaces type matching
var (
_ StreamClient = (*Client)(nil)
_ StreamChannel = (*Channel)(nil)
)
// StreamClient is a client for chat
type StreamClient interface {
// app.go
GetAppConfig() (*AppConfig, error)
UpdateAppSettings(settings *AppSettings) error
// device.go
AddDevice(device *Device) error
DeleteDevice(userID string, deviceID string) error
GetDevices(userID string) (devices []*Device, err error)
// channel.go
CreateChannel(chanType string, chanID string, userID string, data map[string]interface{}) (*Channel, error)
// channel_type.go
CreateChannelType(chType *ChannelType) (*ChannelType, error)
DeleteChannelType(chType string) error
GetChannelType(chanType string) (ct *ChannelType, err error)
ListChannelTypes() (map[string]*ChannelType, error)
UpdateChannelType(name string, options map[string]interface{}) error
// client.go
CreateToken(userID string, expire time.Time) ([]byte, error)
VerifyWebhook(body []byte, signature []byte) (valid bool)
// message.go
DeleteMessage(msgID string) error
GetMessage(msgID string) (*Message, error)
MarkAllRead(userID string) error
UpdateMessage(msg *Message, msgID string) (*Message, error)
FlagMessage(msgID string) error
UnflagMessage(msgID string) error
// query.go
QueryUsers(q *QueryOption, sort ...*SortOption) ([]*User, error)
QueryChannels(q *QueryOption, sort ...*SortOption) ([]*Channel, error)
Search(request SearchRequest) ([]*Message, error)
// user.go
BanUser(targetID string, userID string, options map[string]interface{}) error
DeactivateUser(targetID string, options map[string]interface{}) error
ReactivateUser(targetID string, options map[string]interface{}) error
DeleteUser(targetID string, options map[string][]string) error
ExportUser(targetID string, options map[string][]string) (user *User, err error)
FlagUser(targetID string, options map[string]interface{}) error
MuteUser(targetID string, userID string) error
MuteUsers(targetIDs []string, userID string) error
UnBanUser(targetID string, options map[string]string) error
UnFlagUser(targetID string, options map[string]interface{}) error
UnmuteUser(targetID string, userID string) error
UnmuteUsers(targetIDs []string, userID string) error
UpdateUser(user *User) (*User, error)
UpdateUsers(users ...*User) (map[string]*User, error)
PartialUpdateUser(update PartialUserUpdate) (*User, error)
PartialUpdateUsers(updates []PartialUserUpdate) (map[string]*User, error)
}
// StreamChannel is a channel of communication
type StreamChannel interface {
// channel.go
AddMembers(userIDs []string, message *Message) error
AddModerators(userIDs ...string) error
AddModeratorsWithMessage(userIDs []string, msg *Message) error
BanUser(targetID string, userID string, options map[string]interface{}) error
Delete() error
DemoteModerators(userIDs ...string) error
DemoteModeratorsWithMessage(userIDs []string, msg *Message) error
MarkRead(userID string, options map[string]interface{}) error
RemoveMembers(userIDs []string, message *Message) error
Truncate() error
UnBanUser(targetID string, options map[string]string) error
Update(options map[string]interface{}, message *Message) error
Query(data map[string]interface{}) error
Show(userID string) error
Hide(userID string) error
HideWithHistoryClear(userID string) error
InviteMembers(userIDs ...string) error
InviteMembersWithMessage(userIDs []string, msg *Message) error
SendFile(request SendFileRequest) (url string, err error)
SendImage(request SendFileRequest) (url string, err error)
DeleteFile(location string) error
DeleteImage(location string) error
AcceptInvite(userID string, message *Message) error
RejectInvite(userID string, message *Message) error
// event.go
SendEvent(event *Event, userID string) error
// message.go
SendMessage(message *Message, userID string) (*Message, error)
GetReplies(parentID string, options map[string][]string) (replies []*Message, err error)
SendAction(msgID string, formData map[string]string) (*Message, error)
// reaction.go
DeleteReaction(messageID string, reactionType string, userID string) (*Message, error)
GetReactions(messageID string, options map[string][]string) ([]*Reaction, error)
SendReaction(reaction *Reaction, messageID string, userID string) (*Message, error)
}