feat: Enhance real-time collaboration features with user awareness and document sharing
- Added user information (UserID, UserName, UserAvatar) to Client struct for presence tracking. - Implemented failure handling in the broadcastMessage function to manage send failures and disconnect clients if necessary. - Introduced document ownership and sharing capabilities: - Added OwnerID and Is_Public fields to Document model. - Created DocumentShare model for managing document sharing with permissions. - Implemented functions for creating, listing, and managing document shares in the Postgres store. - Added user management functionality: - Created User model and associated functions for user management in the Postgres store. - Implemented session management with token hashing for security. - Updated database schema with migrations for users, sessions, and document shares. - Enhanced frontend Yjs integration with awareness event logging for user connections and disconnections.
This commit is contained in:
30
backend/internal/models/share.go
Normal file
30
backend/internal/models/share.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type DocumentShare struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
DocumentID uuid.UUID `json:"document_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Permission string `json:"permission"` // "view" or "edit"
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
CreatedBy *uuid.UUID `json:"created_by"`
|
||||
}
|
||||
|
||||
type CreateShareRequest struct {
|
||||
UserEmail string `json:"user_email" binding:"required"`
|
||||
Permission string `json:"permission" binding:"required,oneof=view edit"`
|
||||
}
|
||||
|
||||
type ShareListResponse struct {
|
||||
Shares []DocumentShareWithUser `json:"shares"`
|
||||
}
|
||||
|
||||
type DocumentShareWithUser struct {
|
||||
DocumentShare
|
||||
User User `json:"user"`
|
||||
}
|
||||
Reference in New Issue
Block a user