add api enpoint for creating rooms
This commit is contained in:
parent
0697c3b9d0
commit
d88c279c34
3 changed files with 33 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ import (
|
|||
"mxclientlib/mxutils"
|
||||
"unsafe"
|
||||
|
||||
"maunium.net/go/mautrix"
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
||||
|
|
@ -359,6 +360,32 @@ func apiv0_joinedrooms(cid C.int) *C.char {
|
|||
return C.CString(s)
|
||||
}
|
||||
|
||||
//export apiv0_createroom
|
||||
func apiv0_createroom(cid C.int, data *C.char) *C.char {
|
||||
cli, err := getClient(int(cid))
|
||||
if err != nil {
|
||||
return C.CString(fmt.Sprintf("ERR: %v", err))
|
||||
}
|
||||
|
||||
var req mautrix.ReqCreateRoom
|
||||
err = json.Unmarshal([]byte(C.GoString(data)), &req)
|
||||
if err != nil {
|
||||
return C.CString(fmt.Sprintf("ERR: %v", err))
|
||||
}
|
||||
|
||||
resp, err := cli.CreateRoom(context.Background(), &req)
|
||||
if err != nil {
|
||||
return C.CString(fmt.Sprintf("ERR: %v", err))
|
||||
}
|
||||
|
||||
out, err := json.Marshal(resp)
|
||||
if err != nil {
|
||||
return C.CString(fmt.Sprintf("ERR: %v", err))
|
||||
}
|
||||
s := string(out)
|
||||
return C.CString(s)
|
||||
}
|
||||
|
||||
//export apiv0_removeclient
|
||||
func apiv0_removeclient(cid C.int) C.int {
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue