- 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.
42 lines
937 B
Go
42 lines
937 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type DocumentType string
|
|
|
|
const (
|
|
DocumentTypeEditor DocumentType = "editor"
|
|
DocumentTypeKanban DocumentType = "kanban"
|
|
)
|
|
|
|
type Document struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
Type DocumentType `json:"type"`
|
|
YjsState []byte `json:"-"`
|
|
OwnerID *uuid.UUID `json:"owner_id"` // NEW
|
|
Is_Public bool `json:"is_public"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
|
|
type CreateDocumentRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
Type DocumentType `json:"type" binding:"required"`
|
|
}
|
|
|
|
type UpdateStateRequest struct {
|
|
State []byte `json:"state" binding:"required"`
|
|
}
|
|
|
|
type DocumentListResponse struct {
|
|
Documents []Document `json:"documents"`
|
|
Total int `json:"total"`
|
|
}
|
|
|