4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-26 12:09:22 +00:00

Update go-nc-talk (nctalk) (#1333)

Signed-off-by: Gary Kim <gary@garykim.dev>
This commit is contained in:
Gary Kim
2020-12-10 07:06:27 +08:00
committed by GitHub
parent 0d7315249d
commit 41b4e64be9
10 changed files with 87 additions and 45 deletions

View File

@ -87,38 +87,38 @@ type Capabilities struct {
// RoomInfo contains information about a room
type RoomInfo struct {
Token string `json:"token"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
SessionID string `json:"sessionId"`
ObjectType string `json:"objectType"`
ObjectID string `json:"objectId"`
Type int `json:"type"`
ParticipantType int `json:"participantType"`
ParticipantFlags int `json:"participantFlags"`
ReadOnly int `json:"readOnly"`
LastPing int `json:"lastPing"`
LastActivity int `json:"lastActivity"`
NotificationLevel int `json:"notificationLevel"`
LobbyState int `json:"lobbyState"`
LobbyTimer int `json:"lobbyTimer"`
UnreadMessages int `json:"unreadMessages"`
LastReadMessage int `json:"lastReadMessage"`
HasPassword bool `json:"hasPassword"`
HasCall bool `json:"hasCall"`
CanStartCall bool `json:"canStartCall"`
CanDeleteConversation bool `json:"canDeleteConversation"`
CanLeaveConversation bool `json:"canLeaveConversation"`
IsFavorite bool `json:"isFavorite"`
UnreadMention bool `json:"unreadMention"`
LastMessage ocs.TalkRoomMessageData `json:"lastMessage"`
Token string `json:"token"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
SessionID string `json:"sessionId"`
ObjectType string `json:"objectType"`
ObjectID string `json:"objectId"`
Type int `json:"type"`
ParticipantType int `json:"participantType"`
ParticipantFlags int `json:"participantFlags"`
ReadOnly int `json:"readOnly"`
LastPing int `json:"lastPing"`
LastActivity int `json:"lastActivity"`
NotificationLevel int `json:"notificationLevel"`
LobbyState int `json:"lobbyState"`
LobbyTimer int `json:"lobbyTimer"`
UnreadMessages int `json:"unreadMessages"`
LastReadMessage int `json:"lastReadMessage"`
HasPassword bool `json:"hasPassword"`
HasCall bool `json:"hasCall"`
CanStartCall bool `json:"canStartCall"`
CanDeleteConversation bool `json:"canDeleteConversation"`
CanLeaveConversation bool `json:"canLeaveConversation"`
IsFavorite bool `json:"isFavorite"`
UnreadMention bool `json:"unreadMention"`
LastMessage *ocs.TalkRoomMessageData `json:"lastMessage"`
}
// NewUser returns a TalkUser instance
// The url should be the full URL of the Nextcloud instance (e.g. https://cloud.mydomain.me)
func NewUser(url string, username string, password string, config *TalkUserConfig) (*TalkUser, error) {
return &TalkUser{
NextcloudURL: url,
NextcloudURL: strings.TrimSuffix(url, "/"),
User: username,
Pass: password,
Config: config,
@ -143,7 +143,11 @@ func (t *TalkUser) RequestClient(client request.Client) *request.Client {
// Set Nextcloud URL if there is no host
if !strings.HasPrefix(client.URL, t.NextcloudURL) {
client.URL = t.NextcloudURL + "/" + client.URL
if strings.HasPrefix(client.URL, "/") {
client.URL = t.NextcloudURL + client.URL
} else {
client.URL = t.NextcloudURL + "/" + client.URL
}
}
// Set TLS Config