%% JCHAT Record Definitions %% User record for authentication and profile management -record(user, { id, % binary() - Unique user ID (UUID) email, % binary() - Email address (unique) password_hash, % binary() - Hashed password (bcrypt) display_name, % binary() - Display name for UI created_at, % binary() - ISO8601 timestamp last_login_at, % binary() | null - Last login time is_active, % boolean() - Account active status auth_provider, % binary() - 'local' | 'google' | 'github' etc auth_provider_id % binary() | null - External provider user ID }). %% Session record for tracking active sessions -record(session, { id, % binary() - Session token/ID user_id, % binary() - User ID created_at, % binary() - ISO8601 timestamp expires_at, % binary() - ISO8601 timestamp ip_address, % binary() - Client IP user_agent % binary() - Client user agent }). %% Conversation record -record(conversation, { id, % binary() - Conversation ID title, % binary() | null - Conversation title description, % binary() | null - Description conversation_type, % binary() - 'direct' | 'group' | 'channel' | 'announcement' privacy_level, % binary() - 'private' | 'public' | 'restricted' created_at, % binary() - ISO8601 timestamp updated_at, % binary() - ISO8601 timestamp created_by, % binary() - Creator user ID is_archived, % boolean() - Archived status is_muted, % boolean() - Muted status for notifications participant_ids, % [binary()] - Participant IDs last_message_id, % binary() | null - Last message ID last_message_at, % binary() | null - Last message timestamp unread_count, % integer() - Unread message count message_count, % integer() - Total message count settings, % map() - Conversation settings metadata % map() - Additional conversation data }). %% Message record -record(message, { id, % binary() - Message ID conversation_id, % binary() - Conversation ID sender_id, % binary() - Sender user ID body, % binary() - Message content body_type, % binary() - Content type (text/plain, text/html, etc) sent_at, % binary() - ISO8601 timestamp received_at, % binary() - ISO8601 timestamp (when delivered to server) edited_at, % binary() | null - Edit timestamp is_deleted, % boolean() - Soft delete flag is_system_message, % boolean() - System/automated message flag reply_to_message_id, % binary() | null - Reply reference attachments, % [map()] - Attachment metadata reactions, % [map()] - Message reactions delivery_status, % binary() - 'sent' | 'delivered' | 'read' | 'failed' read_by, % [binary()] - List of user IDs who have read this message metadata % map() - Additional message data }). %% Participant record -record(participant, { id, % binary() - Participant ID conversation_id, % binary() - Conversation ID user_id, % binary() - User ID display_name, % binary() - Display name at time of joining avatar_blob_id, % binary() | null - Avatar image blob ID role, % binary() - 'owner' | 'admin' | 'moderator' | 'member' joined_at, % binary() - ISO8601 timestamp left_at, % binary() | null - Leave timestamp last_active_at, % binary() | null - Last activity timestamp is_active, % boolean() - Active in conversation permissions, % [binary()] - Specific permissions last_read_message_id, % binary() | null - Last read message last_read_at, % binary() | null - Last read timestamp metadata % map() - Additional participant data }). %% Presence record -record(presence, { user_id, % binary() - User ID status, % binary() - 'online' | 'away' | 'busy' | 'offline' status_message, % binary() | null - Custom status message last_seen_at, % binary() - ISO8601 timestamp is_typing_in, % binary() | null - Conversation ID if typing updated_at % binary() - ISO8601 timestamp }). %% State counter for JMAP synchronization -record(state_counter, { account_id, % binary() - Account ID object_type, % binary() - Object type (conversation, message, etc) state, % binary() - Current state value updated_at % binary() - ISO8601 timestamp }). %% Role definition for RBAC -record(role, { id, % binary() - Role ID name, % binary() - Human readable name description, % binary() - Role description permissions, % [binary()] - List of permission strings is_system, % boolean() - System role vs user-defined created_at % binary() - ISO8601 timestamp }). %% User role assignments (system-wide) -record(user_role, { user_id, % binary() - User ID role_id, % binary() - Role ID granted_by, % binary() - User ID who granted the role granted_at % binary() - ISO8601 timestamp }). %% Conversation-specific role assignments -record(conversation_role, { user_id, % binary() - User ID conversation_id, % binary() - Conversation ID role_id, % binary() - Role ID granted_by, % binary() - User ID who granted the role granted_at % binary() - ISO8601 timestamp }).