fix(collab): fix corporate SSE fallback, realtime lock propagation and prevent stale overwrite
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m1s

This commit is contained in:
sandrodach committed 2026-10-27 15:21:05 +01:00
1 parent 996f27133c
commit a1c7a65d84
5 files changed
+238 -63

No files matched your search

+19 -10
View File
@@ -861,11 +861,18 @@ func (s *Server) broadcastDocToAuthorizedUsers(docID, event string) {
if err != nil {
return
}
var firstDoc *domain.Document
for _, uid := range users {
if userDoc, err := s.store.GetDocumentByID(uid, docID); err == nil && userDoc != nil {
if firstDoc == nil {
firstDoc = userDoc
}
s.wsHub.BroadcastToUser(uid, event, userDoc)
}
}
if s.wsHub != nil && firstDoc != nil {
s.wsHub.BroadcastRoom("doc:"+docID, event, firstDoc, nil)
}
}
func (s *Server) handleGetDocuments(w http.ResponseWriter, r *http.Request) {
@@ -1516,16 +1523,18 @@ func (s *Server) handleUnlockBlock(w http.ResponseWriter, r *http.Request) {
blockID := chi.URLParam(r, "blockId")
if s.wsHub != nil {
s.wsHub.ReleaseBlockLock(docID, blockID, userID)
evt := map[string]string{
"docId": docID,
"blockId": blockID,
"userId": userID,
}
s.wsHub.BroadcastRoom("doc:"+docID, "DOC_BLOCK_UNLOCKED", evt, nil)
if users, err := s.store.GetAuthorizedDocUsers(docID); err == nil {
for _, uid := range users {
s.wsHub.BroadcastToUser(uid, "DOC_BLOCK_UNLOCKED", evt)
released := s.wsHub.ReleaseBlockLock(docID, blockID, userID)
if released {
evt := map[string]string{
"docId": docID,
"blockId": blockID,
"userId": userID,
}
s.wsHub.BroadcastRoom("doc:"+docID, "DOC_BLOCK_UNLOCKED", evt, nil)
if users, err := s.store.GetAuthorizedDocUsers(docID); err == nil {
for _, uid := range users {
s.wsHub.BroadcastToUser(uid, "DOC_BLOCK_UNLOCKED", evt)
}
}
}
}