-
Notifications
You must be signed in to change notification settings - Fork 0
/
instantMessaging.go
60 lines (54 loc) · 1.92 KB
/
instantMessaging.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
package connect
import "encoding/json"
type XmppSettings struct {
SendOutsideEnabled bool `json:"sendOutsideEnabled"` // Sending messages outside the company is enabled
SendOutsideEnabledIsRunning bool `json:"sendOutsideEnabledIsRunning"` // [READ-ONLY] Sending messages outside the company is really running and is functional
}
type XMPPConfiguration struct {
DnsARecord bool `json:"dnsARecord"`
DnsSRVRecordClient bool `json:"dnsSRVRecordClient"`
DnsSRVRecordServer bool `json:"dnsSRVRecordServer"`
XmppPingExternalServer bool `json:"xmppPingExternalServer"`
}
// InstantMessagingGet - Get settings of XMPP server
// Return
// settings - Sign On settings
func (s *ServerConnection) InstantMessagingGet() (*XmppSettings, error) {
data, err := s.CallRaw("InstantMessaging.get", nil)
if err != nil {
return nil, err
}
settings := struct {
Result struct {
Settings XmppSettings `json:"settings"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &settings)
return &settings.Result.Settings, err
}
// InstantMessagingSet - Set settings of XMPP server
// settings - Sign On settings
func (s *ServerConnection) InstantMessagingSet(settings XmppSettings) error {
params := struct {
Settings XmppSettings `json:"settings"`
}{settings}
_, err := s.CallRaw("InstantMessaging.set", params)
return err
}
// InstantMessagingCheckXMPPConfiguration - Check XMPP configuration for all domains
func (s *ServerConnection) InstantMessagingCheckXMPPConfiguration(domainId KId) (*XMPPConfiguration, error) {
params := struct {
DomainId KId `json:"domainId"`
}{domainId}
data, err := s.CallRaw("InstantMessaging.checkXMPPConfiguration", params)
if err != nil {
return nil, err
}
configuration := struct {
Result struct {
Configuration XMPPConfiguration `json:"configuration"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &configuration)
return &configuration.Result.Configuration, err
}