instant그룹에서 _id를 클라이언트에는 감춤
This commit is contained in:
@ -162,6 +162,7 @@ func (gi *groupInstant) join(gd *instantDoc, mid primitive.ObjectID, character a
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
delete(memdoc, "_id")
|
||||
|
||||
// 기존 유저에게 새 유저 알림
|
||||
gi.sendUpstreamMessage(&wshandler.UpstreamMessage{
|
||||
@ -174,10 +175,18 @@ func (gi *groupInstant) join(gd *instantDoc, mid primitive.ObjectID, character a
|
||||
|
||||
gi.rh.JSONSet(mid.Hex(), "$.instant", bson.M{"id": gd.strid()})
|
||||
|
||||
full := gd.loadFull()
|
||||
if f, ok := full["_members"]; ok {
|
||||
members := f.(map[string]any)
|
||||
for _, char := range members {
|
||||
delete(char.(map[string]any), "_id")
|
||||
}
|
||||
}
|
||||
|
||||
// 최초 입장이라면 새 멤버에 그룹 전체를 알림
|
||||
gi.sendUpstreamMessage(&wshandler.UpstreamMessage{
|
||||
Target: mid.Hex(),
|
||||
Body: gd.loadFull(),
|
||||
Body: full,
|
||||
Tag: []string{"GroupDocFull"},
|
||||
})
|
||||
gi.enterRoom(gd.Gid, mid)
|
||||
@ -215,14 +224,17 @@ func (gi *groupInstant) UpdateInstantDocument(w http.ResponseWriter, r *http.Req
|
||||
})
|
||||
|
||||
if data.Result == "after" {
|
||||
raws, err := gi.rh.JSONGetDocuments(data.Gid.Hex(), "$")
|
||||
if err != nil {
|
||||
logger.Println("QueryInstantDocument failed. JSONGetDocuments returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
fulldoc := gd.loadFull()
|
||||
if fulldoc != nil {
|
||||
tids := fulldoc["_members"].(map[string]any)
|
||||
mids := make(map[string]any)
|
||||
for k, v := range tids {
|
||||
mid := midFromTid(data.Gid, k)
|
||||
mids[mid.Hex()] = v
|
||||
}
|
||||
fulldoc["_members"] = mids
|
||||
}
|
||||
|
||||
gocommon.MakeEncoder(w, r).Encode(raws[0])
|
||||
gocommon.MakeEncoder(w, r).Encode(fulldoc)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user