Changes
This commit is contained in:
parent
9eac960763
commit
da9196f389
22 changed files with 302 additions and 76 deletions
|
@ -1,6 +1,6 @@
|
|||
package room
|
||||
|
||||
import "nutfactory.org/Matrix/entities/event"
|
||||
import "git.nutfactory.org/hoernschen/Matrix/entities/event"
|
||||
|
||||
type Room struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
|
@ -15,7 +15,7 @@ type Room struct {
|
|||
Federated bool `json:"federated,omitempty"`
|
||||
}
|
||||
|
||||
type createRoomRequest struct {
|
||||
type CreateRoomRequest struct {
|
||||
Visibility string `json:"visibility,omitempty"`
|
||||
RoomAliasName string `json:"room_alias_name,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
|
@ -23,14 +23,14 @@ type createRoomRequest struct {
|
|||
Invite string `json:"invite,omitempty"`
|
||||
Invite3pid invite3pid `json:"invite_3pid,omitempty"`
|
||||
RoomVersion string `json:"room_version,omitempty"`
|
||||
CreationContent creationContent `json:"creation_content,omitempty"`
|
||||
CreationContent CreationContent `json:"creation_content,omitempty"`
|
||||
InitialState []event.StateEvent `json:"initial_state,omitempty"`
|
||||
Preset string `json:"preset,omitempty"`
|
||||
IsDirect bool `json:"is_direct,omitempty"`
|
||||
PowerLevelContentOverride string `json:"power_level_content_override,omitempty"`
|
||||
}
|
||||
|
||||
type createRoomResponse struct {
|
||||
type CreateRoomResponse struct {
|
||||
RoomId string `json:"room_id,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,11 @@ type getRoomMemberResponse struct {
|
|||
Chunk []*event.Event `json:"chunk,omitempty"`
|
||||
}
|
||||
|
||||
type joinRoomUserRequest struct {
|
||||
type JoinRoomUserRequest struct {
|
||||
ThirdPartySigned thirdPartySigned `json:"third_party_signed,omitempty"`
|
||||
}
|
||||
|
||||
type joinRoomUserResponse struct {
|
||||
type JoinRoomUserResponse struct {
|
||||
RoomId string `json:"room_id,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ type invite3pid struct {
|
|||
Address string `json:"address,omitempty"`
|
||||
}
|
||||
|
||||
type creationContent struct {
|
||||
type CreationContent struct {
|
||||
Federated bool `json:"m.federate,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"git.nutfactory.org/hoernschen/Matrix/config"
|
||||
"git.nutfactory.org/hoernschen/Matrix/entities/event"
|
||||
"git.nutfactory.org/hoernschen/Matrix/entities/user"
|
||||
"git.nutfactory.org/hoernschen/Matrix/utils"
|
||||
"github.com/cenkalti/backoff/v4"
|
||||
"github.com/gorilla/mux"
|
||||
"nutfactory.org/Matrix/config"
|
||||
"nutfactory.org/Matrix/entities/event"
|
||||
"nutfactory.org/Matrix/entities/user"
|
||||
"nutfactory.org/Matrix/utils"
|
||||
)
|
||||
|
||||
func New(
|
||||
|
@ -47,7 +47,7 @@ func New(
|
|||
|
||||
func CreateRoomHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
request := createRoomRequest{}
|
||||
request := CreateRoomRequest{}
|
||||
errResponse := utils.CheckRequest(r)
|
||||
if errResponse != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
|
@ -315,7 +315,7 @@ func CreateRoomHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
response := createRoomResponse{RoomId: newRoom.Id}
|
||||
response := CreateRoomResponse{RoomId: newRoom.Id}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||
panic(err)
|
||||
|
@ -378,7 +378,7 @@ func GetRoomMemberHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func JoinRoomUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
request := joinRoomUserRequest{}
|
||||
request := JoinRoomUserRequest{}
|
||||
errResponse := utils.CheckRequest(r)
|
||||
if errResponse != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
|
@ -578,7 +578,7 @@ func JoinRoomUserHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
return
|
||||
}
|
||||
response := joinRoomUserResponse{RoomId: roomId}
|
||||
response := JoinRoomUserResponse{RoomId: roomId}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -3,8 +3,8 @@ package room
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"nutfactory.org/Matrix/entities/event"
|
||||
"nutfactory.org/Matrix/utils/database"
|
||||
"git.nutfactory.org/hoernschen/Matrix/entities/event"
|
||||
"git.nutfactory.org/hoernschen/Matrix/utils/database"
|
||||
)
|
||||
|
||||
func CreateRoom(room *Room) (err error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue