mirror of
https://github.com/pushbits/server.git
synced 2025-05-19 03:46:34 +02:00
Initialize repository
This commit is contained in:
commit
1d758fcfd0
28 changed files with 1107 additions and 0 deletions
29
dispatcher/application.go
Normal file
29
dispatcher/application.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package dispatcher
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/matrix-org/gomatrix"
|
||||
)
|
||||
|
||||
// RegisterApplication creates a new channel for the application.
|
||||
func (d *Dispatcher) RegisterApplication(name, user string) (string, error) {
|
||||
log.Printf("Registering application %s, notifications will be relayed to user %s.\n", name, user)
|
||||
|
||||
response, err := d.client.CreateRoom(&gomatrix.ReqCreateRoom{
|
||||
Visibility: "private",
|
||||
Name: name,
|
||||
Invite: []string{user},
|
||||
Preset: "private_chat",
|
||||
IsDirect: true,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
log.Printf("Application %s is now relayed to room with ID %s.\n", name, response.RoomID)
|
||||
|
||||
return response.RoomID, err
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue