Refactor and update RocketChat bridge
* Add support for editing/deleting messages * Add support for uploading files * Add support for avatars * Use the Rocket.Chat.Go.SDK * Use the rest and streaming api
This commit is contained in:
39
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/channel.go
generated
vendored
Normal file
39
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/channel.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Channel struct {
|
||||
ID string `json:"_id"`
|
||||
Name string `json:"name"`
|
||||
Fname string `json:"fname,omitempty"`
|
||||
Type string `json:"t"`
|
||||
Msgs int `json:"msgs"`
|
||||
|
||||
ReadOnly bool `json:"ro,omitempty"`
|
||||
SysMes bool `json:"sysMes,omitempty"`
|
||||
Default bool `json:"default"`
|
||||
Broadcast bool `json:"broadcast,omitempty"`
|
||||
|
||||
Timestamp *time.Time `json:"ts,omitempty"`
|
||||
UpdatedAt *time.Time `json:"_updatedAt,omitempty"`
|
||||
|
||||
User *User `json:"u,omitempty"`
|
||||
LastMessage *Message `json:"lastMessage,omitempty"`
|
||||
|
||||
// Lm interface{} `json:"lm"`
|
||||
// CustomFields struct {
|
||||
// } `json:"customFields,omitempty"`
|
||||
}
|
||||
|
||||
type ChannelSubscription struct {
|
||||
ID string `json:"_id"`
|
||||
Alert bool `json:"alert"`
|
||||
Name string `json:"name"`
|
||||
DisplayName string `json:"fname"`
|
||||
Open bool `json:"open"`
|
||||
RoomId string `json:"rid"`
|
||||
Type string `json:"c"`
|
||||
User User `json:"u"`
|
||||
Roles []string `json:"roles"`
|
||||
Unread float64 `json:"unread"`
|
||||
}
|
||||
133
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/info.go
generated
vendored
Normal file
133
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/info.go
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Info struct {
|
||||
Version string `json:"version"`
|
||||
|
||||
Build struct {
|
||||
NodeVersion string `json:"nodeVersion"`
|
||||
Arch string `json:"arch"`
|
||||
Platform string `json:"platform"`
|
||||
Cpus int `json:"cpus"`
|
||||
} `json:"build"`
|
||||
|
||||
Commit struct {
|
||||
Hash string `json:"hash"`
|
||||
Date string `json:"date"`
|
||||
Author string `json:"author"`
|
||||
Subject string `json:"subject"`
|
||||
Tag string `json:"tag"`
|
||||
Branch string `json:"branch"`
|
||||
} `json:"commit"`
|
||||
}
|
||||
|
||||
type Pagination struct {
|
||||
Count int `json:"count"`
|
||||
Offset int `json:"offset"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type Directory struct {
|
||||
Result []struct {
|
||||
ID string `json:"_id"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Emails []struct {
|
||||
Address string `json:"address"`
|
||||
Verified bool `json:"verified"`
|
||||
} `json:"emails"`
|
||||
Name string `json:"name"`
|
||||
Username string `json:"username"`
|
||||
} `json:"result"`
|
||||
|
||||
Pagination
|
||||
}
|
||||
|
||||
type Spotlight struct {
|
||||
Users []User `json:"users"`
|
||||
Rooms []Channel `json:"rooms"`
|
||||
}
|
||||
|
||||
type Statistics struct {
|
||||
ID string `json:"_id"`
|
||||
UniqueID string `json:"uniqueId"`
|
||||
Version string `json:"version"`
|
||||
|
||||
ActiveUsers int `json:"activeUsers"`
|
||||
NonActiveUsers int `json:"nonActiveUsers"`
|
||||
OnlineUsers int `json:"onlineUsers"`
|
||||
AwayUsers int `json:"awayUsers"`
|
||||
OfflineUsers int `json:"offlineUsers"`
|
||||
TotalUsers int `json:"totalUsers"`
|
||||
|
||||
TotalRooms int `json:"totalRooms"`
|
||||
TotalChannels int `json:"totalChannels"`
|
||||
TotalPrivateGroups int `json:"totalPrivateGroups"`
|
||||
TotalDirect int `json:"totalDirect"`
|
||||
TotlalLivechat int `json:"totlalLivechat"`
|
||||
TotalMessages int `json:"totalMessages"`
|
||||
TotalChannelMessages int `json:"totalChannelMessages"`
|
||||
TotalPrivateGroupMessages int `json:"totalPrivateGroupMessages"`
|
||||
TotalDirectMessages int `json:"totalDirectMessages"`
|
||||
TotalLivechatMessages int `json:"totalLivechatMessages"`
|
||||
|
||||
InstalledAt time.Time `json:"installedAt"`
|
||||
LastLogin time.Time `json:"lastLogin"`
|
||||
LastMessageSentAt time.Time `json:"lastMessageSentAt"`
|
||||
LastSeenSubscription time.Time `json:"lastSeenSubscription"`
|
||||
|
||||
Os struct {
|
||||
Type string `json:"type"`
|
||||
Platform string `json:"platform"`
|
||||
Arch string `json:"arch"`
|
||||
Release string `json:"release"`
|
||||
Uptime int `json:"uptime"`
|
||||
Loadavg []float64 `json:"loadavg"`
|
||||
Totalmem int64 `json:"totalmem"`
|
||||
Freemem int `json:"freemem"`
|
||||
Cpus []struct {
|
||||
Model string `json:"model"`
|
||||
Speed int `json:"speed"`
|
||||
Times struct {
|
||||
User int `json:"user"`
|
||||
Nice int `json:"nice"`
|
||||
Sys int `json:"sys"`
|
||||
Idle int `json:"idle"`
|
||||
Irq int `json:"irq"`
|
||||
} `json:"times"`
|
||||
} `json:"cpus"`
|
||||
} `json:"os"`
|
||||
|
||||
Process struct {
|
||||
NodeVersion string `json:"nodeVersion"`
|
||||
Pid int `json:"pid"`
|
||||
Uptime float64 `json:"uptime"`
|
||||
} `json:"process"`
|
||||
|
||||
Deploy struct {
|
||||
Method string `json:"method"`
|
||||
Platform string `json:"platform"`
|
||||
} `json:"deploy"`
|
||||
|
||||
Migration struct {
|
||||
ID string `json:"_id"`
|
||||
Version int `json:"version"`
|
||||
Locked bool `json:"locked"`
|
||||
LockedAt time.Time `json:"lockedAt"`
|
||||
BuildAt time.Time `json:"buildAt"`
|
||||
} `json:"migration"`
|
||||
|
||||
InstanceCount int `json:"instanceCount"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"_updatedAt"`
|
||||
}
|
||||
|
||||
type StatisticsInfo struct {
|
||||
Statistics Statistics `json:"statistics"`
|
||||
}
|
||||
|
||||
type StatisticsList struct {
|
||||
Statistics []Statistics `json:"statistics"`
|
||||
|
||||
Pagination
|
||||
}
|
||||
75
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/message.go
generated
vendored
Normal file
75
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/message.go
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Message struct {
|
||||
ID string `json:"_id"`
|
||||
RoomID string `json:"rid"`
|
||||
Msg string `json:"msg"`
|
||||
EditedBy string `json:"editedBy,omitempty"`
|
||||
|
||||
Groupable bool `json:"groupable,omitempty"`
|
||||
|
||||
EditedAt *time.Time `json:"editedAt,omitempty"`
|
||||
Timestamp *time.Time `json:"ts,omitempty"`
|
||||
UpdatedAt *time.Time `json:"_updatedAt,omitempty"`
|
||||
|
||||
Mentions []User `json:"mentions,omitempty"`
|
||||
User *User `json:"u,omitempty"`
|
||||
PostMessage
|
||||
|
||||
// Bot interface{} `json:"bot"`
|
||||
// CustomFields interface{} `json:"customFields"`
|
||||
// Channels []interface{} `json:"channels"`
|
||||
// SandstormSessionID interface{} `json:"sandstormSessionId"`
|
||||
}
|
||||
|
||||
// PostMessage Payload for postmessage rest API
|
||||
//
|
||||
// https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage/
|
||||
type PostMessage struct {
|
||||
RoomID string `json:"roomId,omitempty"`
|
||||
Channel string `json:"channel,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
ParseUrls bool `json:"parseUrls,omitempty"`
|
||||
Alias string `json:"alias,omitempty"`
|
||||
Emoji string `json:"emoji,omitempty"`
|
||||
Avatar string `json:"avatar,omitempty"`
|
||||
Attachments []Attachment `json:"attachments,omitempty"`
|
||||
}
|
||||
|
||||
// Attachment Payload for postmessage rest API
|
||||
//
|
||||
// https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage/
|
||||
type Attachment struct {
|
||||
Color string `json:"color,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
Timestamp string `json:"ts,omitempty"`
|
||||
ThumbURL string `json:"thumb_url,omitempty"`
|
||||
MessageLink string `json:"message_link,omitempty"`
|
||||
Collapsed bool `json:"collapsed"`
|
||||
|
||||
AuthorName string `json:"author_name,omitempty"`
|
||||
AuthorLink string `json:"author_link,omitempty"`
|
||||
AuthorIcon string `json:"author_icon,omitempty"`
|
||||
|
||||
Title string `json:"title,omitempty"`
|
||||
TitleLink string `json:"title_link,omitempty"`
|
||||
TitleLinkDownload string `json:"title_link_download,omitempty"`
|
||||
|
||||
ImageURL string `json:"image_url,omitempty"`
|
||||
|
||||
AudioURL string `json:"audio_url,omitempty"`
|
||||
VideoURL string `json:"video_url,omitempty"`
|
||||
|
||||
Fields []AttachmentField `json:"fields,omitempty"`
|
||||
}
|
||||
|
||||
// AttachmentField Payload for postmessage rest API
|
||||
//
|
||||
// https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage/
|
||||
type AttachmentField struct {
|
||||
Short bool `json:"short"`
|
||||
Title string `json:"title"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
7
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/permission.go
generated
vendored
Normal file
7
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/permission.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package models
|
||||
|
||||
type Permission struct {
|
||||
ID string `json:"_id"`
|
||||
UpdatedAt string `json:"_updatedAt.$date"`
|
||||
Roles []string `json:"roles"`
|
||||
}
|
||||
21
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/setting.go
generated
vendored
Normal file
21
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/setting.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package models
|
||||
|
||||
type Setting struct {
|
||||
ID string `json:"_id"`
|
||||
Blocked bool `json:"blocked"`
|
||||
Group string `json:"group"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Public bool `json:"public"`
|
||||
Type string `json:"type"`
|
||||
PackageValue string `json:"packageValue"`
|
||||
Sorter int `json:"sorter"`
|
||||
Value string `json:"value"`
|
||||
ValueBool bool `json:"valueBool"`
|
||||
ValueInt float64 `json:"valueInt"`
|
||||
ValueSource string `json:"valueSource"`
|
||||
ValueAsset Asset `json:"asset"`
|
||||
}
|
||||
|
||||
type Asset struct {
|
||||
DefaultUrl string `json:"defaultUrl"`
|
||||
}
|
||||
29
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/user.go
generated
vendored
Normal file
29
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/user.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
package models
|
||||
|
||||
type User struct {
|
||||
ID string `json:"_id"`
|
||||
Name string `json:"name"`
|
||||
UserName string `json:"username"`
|
||||
Status string `json:"status"`
|
||||
Token string `json:"token"`
|
||||
TokenExpires int64 `json:"tokenExpires"`
|
||||
}
|
||||
|
||||
type CreateUserRequest struct {
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Username string `json:"username"`
|
||||
CustomFields map[string]string `json:"customFields,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateUserRequest struct {
|
||||
UserID string `json:"userId"`
|
||||
Data struct {
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Username string `json:"username"`
|
||||
CustomFields map[string]string `json:"customFields,omitempty"`
|
||||
} `json:"data"`
|
||||
}
|
||||
10
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/userCredentials.go
generated
vendored
Normal file
10
vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/models/userCredentials.go
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
package models
|
||||
|
||||
type UserCredentials struct {
|
||||
ID string `json:"id"`
|
||||
Token string `json:"token"`
|
||||
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Password string `json:"pass"`
|
||||
}
|
||||
Reference in New Issue
Block a user