mirror of
https://github.com/Unkn0wnCat/matrix-veles.git
synced 2025-07-28 13:57:47 +02:00
api: Add Room configuration changers
This commit is contained in:
parent
adf8bc3ee0
commit
2d68e30ad2
6 changed files with 473 additions and 13 deletions
|
@ -166,6 +166,24 @@ func GetRoomConfigByRoomID(id string) (*RoomConfig, error) {
|
|||
return &object, nil
|
||||
}
|
||||
|
||||
func GetRoomConfigByObjectID(id primitive.ObjectID) (*RoomConfig, error) {
|
||||
database := db.DbClient.Database(viper.GetString("bot.mongo.database"))
|
||||
|
||||
res := database.Collection(viper.GetString("bot.mongo.collection.rooms")).FindOne(context.TODO(), bson.D{{"_id", id}})
|
||||
if res.Err() != nil {
|
||||
return nil, res.Err()
|
||||
}
|
||||
|
||||
object := GetDefaultRoomConfig()
|
||||
|
||||
err := res.Decode(&object)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &object, nil
|
||||
}
|
||||
|
||||
func GetDefaultRoomConfig() RoomConfig {
|
||||
return RoomConfig{
|
||||
ID: primitive.NewObjectID(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue