]> git.example.dev Git - binbsis50-sm.git/commitdiff
update: rooms get function
author2weiEmu <saalbach.robert@outlook.de>
Fri, 1 May 2026 13:09:21 +0000 (15:09 +0200)
committer2weiEmu <saalbach.robert@outlook.de>
Fri, 1 May 2026 13:09:21 +0000 (15:09 +0200)
pkg/dbhandling/roomsapi.go

index 64af91afd4613cd2594c170ff7327ec624a24106..b4f3a455ce045c0115c8c7bcf51c0c61893e5112 100644 (file)
@@ -1,32 +1,60 @@
 package dbhandling
 
-import "net/http"
+import (
+       "net/http"
+)
 
-/** TODO
- *
+/** TEST
+ * Get all the names of all the rooms in the database
  **/
 func (dbw *DBWrapper) RoomsGet(w http.ResponseWriter, r *http.Request) {
+
+       allKeys, err := dbw.RedisDb.Keys(dbw.Ctx, "*").Result()
+       if err != nil {
+               w.WriteHeader(http.StatusInternalServerError)
+               return
+       }
+
+       roomList := make([]string, 0)
+
+       for _, k := range allKeys {
+               t, err := dbw.RedisDb.Type(dbw.Ctx, k).Result()
+               if err != nil {
+                       w.WriteHeader(http.StatusInternalServerError)
+                       return
+               }
+
+               if t == "zset" {
+                       roomList = append(roomList, k)
+               }
+       }
+}
+
+/** TODO TEST
+ *
+ **/
+func (dbw *DBWrapper) RoomsGetByName(w http.ResponseWriter, r *http.Request) {
 }
 
-/** TODO
+/** TODO TEST
  *
  **/
 func (dbw *DBWrapper) RoomsCreate(w http.ResponseWriter, r *http.Request) {
 }
 
-/** TODO
+/** TODO TEST
  *
  **/
 func (dbw *DBWrapper) RoomsAddByNameAndId(w http.ResponseWriter, r *http.Request) {
 }
 
-/** TODO
+/** TODO TEST
  *
  **/
 func (dbw *DBWrapper) RoomsRemoveByNameAndId(w http.ResponseWriter, r *http.Request) {
 }
 
-/** TODO
+/** TODO TEST
  *
  **/
 func (dbw *DBWrapper) RoomsDeleteByName(w http.ResponseWriter, r *http.Request) {