diff --git a/specs/models/biz/user.v b/specs/models/biz/user.v index d064b51..d611948 100644 --- a/specs/models/biz/user.v +++ b/specs/models/biz/user.v @@ -1,19 +1,5 @@ module biz -import base -import freeflowuniverse.herolib.data.ourtime - - -// User represents a user in the Freezone Manager system -pub struct User { - base.Base // Base struct for common fields -pub mut: - id u32 - name string - email string - password string - company string // here its just a best effort - role string - created_at ourtime.OurTime - updated_at ourtime.OurTime -} +// DEPRECATED: This file is deprecated and should not be used. +// Please use circle.User instead, which has all the necessary fields for MCC functionality. +// The biz.User struct has been removed as per the specifications. diff --git a/specs/models/circle/attachment.v b/specs/models/circle/attachment.v new file mode 100644 index 0000000..f956adc --- /dev/null +++ b/specs/models/circle/attachment.v @@ -0,0 +1,15 @@ + +module circle + +// Attachment represents an attachment usable for any object +// such as email, chat, etc. +// It is a generic struct that can be used for any object +// that requires an attachment. + +pub struct Attachment { +pub mut: + filename string + content_type string + hash string // Hash of the attachment data + size u32 // Size in bytes +} diff --git a/specs/models/circle/config.v b/specs/models/circle/config.v new file mode 100644 index 0000000..6f1013e --- /dev/null +++ b/specs/models/circle/config.v @@ -0,0 +1,39 @@ +module mcc +import base + + +//there is only 1 of this per circle called "configs" +pub struct Configs { + base.Base +pub mut: + configs map[string]Config //string is namefixed +} + + +//generic config per circle, can be more than 1 +pub struct Config { + base.Base +pub mut: + name string + labels []Label + colors []Color +} + +pub struct Label { + base.Base +pub mut: + name string + comment string + color u16 +} + + +pub struct Color { + base.Base +pub mut: + id u16 + name string + comment string + colorcode string //hex color code +} + diff --git a/specs/models/circle/user.v b/specs/models/circle/user.v index 901eda6..8ea6b43 100644 --- a/specs/models/circle/user.v +++ b/specs/models/circle/user.v @@ -1,6 +1,6 @@ module circle -// import freeflowuniverse.herolib.data.ourtime +import freeflowuniverse.herolib.data.ourtime import base // Role represents the role of a member in a circle @@ -13,7 +13,17 @@ pub enum Role { external // means no right in this circle appart from we register this user } -// Member represents a member of a circle +// UserPreferences represents user preferences for MCC +pub struct UserPreferences { +pub mut: + default_calendar_id u32 // Default calendar ID + default_view string // Default view (day, week, month) + email_signature string // Default email signature + theme string // UI theme preference + notifications bool // Enable/disable notifications +} + +// User represents a member of a circle pub struct User { base.Base pub mut: @@ -23,5 +33,10 @@ pub mut: contact_ids []u32 // IDs of contacts linked to this member wallet_ids []u32 // IDs of wallets owned by this member which are relevant to this circle pubkey string // public key of the member as used in this circle + + // Additional fields needed for MCC functionality + email string // Primary email address + timezone string // User's preferred timezone + preferences UserPreferences // User preferences for MCC } diff --git a/specs/models/mcc/README.md b/specs/models/mcc/README.md new file mode 100644 index 0000000..7c3c453 --- /dev/null +++ b/specs/models/mcc/README.md @@ -0,0 +1,284 @@ +# MCC (Mail, Calendar, Contacts) Specification + +This document outlines the data models for the MCC system, which is designed to be a self-hosted alternative to Google's Mail, Calendar, and Contacts services with full control over data. + +## Overview + +The MCC system consists of three main components: + +1. **Mail**: A messaging system that can be used for email as well as chat +2. **Calendar**: A calendar system for managing events and appointments +3. **Contacts**: A contact management system + +All components are integrated with the `circle.User` model, which serves as the primary user model for the system. + +## Data Models + +### User Model + +The user model is defined in `circle/user.v` and has been enhanced with additional fields for MCC functionality: + +```v +// User represents a member of a circle +pub struct User { + base.Base +pub mut: + name string // name of the member as used in this circle + description string // optional description which is relevant to this circle + role Role // role of the member in the circle + contact_ids []u32 // IDs of contacts linked to this member + wallet_ids []u32 // IDs of wallets owned by this member which are relevant to this circle + pubkey string // public key of the member as used in this circle + + // Additional fields needed for MCC functionality + email string // Primary email address + timezone string // User's preferred timezone + preferences UserPreferences // User preferences for MCC +} + +// UserPreferences represents user preferences for MCC +pub struct UserPreferences { +pub mut: + default_calendar_id u32 // Default calendar ID + default_view string // Default view (day, week, month) + email_signature string // Default email signature + theme string // UI theme preference + notifications bool // Enable/disable notifications +} +``` + +### Mail Models + +The mail models are defined in `mcc/message.v`: + +```v +// Message represents an email message +pub struct Message { + base.Base +pub mut: + id u32 // Database ID + message_id string // Unique identifier for the email + conversation_id string // ID for grouping messages in the same thread + folder string // The folder this email belongs to (inbox, sent, drafts, etc.) + labels []string // Google-style labels for organization + message string // The email body content + attachments []Attachment // Any file attachments + send_time ourtime.OurTime + + date i64 // Unix timestamp when the email was sent/received + size u32 // Size of the message in bytes + read bool // Whether the email has been read + flagged bool // Whether the email has been flagged/starred + priority string // Priority level (high, normal, low) + + // Header information + subject string + from []u32 // List of user IDs who sent the email + sender []u32 + reply_to []u32 + to []u32 + cc []u32 + bcc []u32 + in_reply_to u32 + + // Additional fields + draft bool // Whether this is a draft message + scheduled_send ourtime.OurTime // Time to send if scheduled +} + +// Attachment represents an email attachment +pub struct Attachment { +pub mut: + filename string + content_type string + hash string // Hash of the attachment data + size u32 // Size in bytes + content []byte // Optional, for storing small attachments directly +} +``` + +### Calendar Models + +The calendar models are defined in `mcc/calendar.v`: + +```v +// Calendar represents a collection of events +pub struct Calendar { + base.Base +pub mut: + name string // Name of the calendar + description string // Description of the calendar + color string // Color for the calendar + owner_id u32 // User who owns this calendar + timezone string // Default timezone for this calendar + visibility string // Public, private, etc. + shared_with []CalendarShare // Users this calendar is shared with +} + +// CalendarShare represents calendar sharing permissions +pub struct CalendarShare { +pub mut: + user_id u32 // User ID this calendar is shared with + permission string // Read, write, owner, etc. +} + +// CalendarEvent represents a calendar event with all its properties +pub struct CalendarEvent { + base.Base +pub mut: + calendar_id u32 // ID of the calendar this event belongs to + title string // Event title + description string // Event details + location string // Event location + start_time ourtime.OurTime + end_time ourtime.OurTime // End time + all_day bool // True if it's an all-day event + recurrence string // RFC 5545 Recurrence Rule (e.g., "FREQ=DAILY;COUNT=10") + attendees []Attendee // List of attendees + organizer u32 // The user who created the event + status string // "CONFIRMED", "CANCELLED", "TENTATIVE" + color string // User-friendly color categorization + reminders []Reminder // Reminders for this event + timezone string // Timezone for this specific event + visibility string // Public, private, etc. + attachments []Attachment // Attachments for this event +} + +// Reminder represents a reminder for an event +pub struct Reminder { +pub mut: + event_id u32 // Event this reminder is for + time ourtime.OurTime // When to send the reminder + method string // How to deliver the reminder (email, notification, etc.) +} + +// Attendee represents an attendee of an event +pub struct Attendee { +pub mut: + user_id u32 // User ID of the attendee + email string // Email of the attendee (for external attendees) + name string // Name of the attendee + response string // "ACCEPTED", "DECLINED", "TENTATIVE", "NEEDS-ACTION" + optional bool // Whether attendance is optional + comment string // Attendee's comment +} +``` + +### Contacts Models + +The contacts models are defined in `mcc/contacts.v`: + +```v +// Contact represents a contact with all their information +pub struct Contact { + base.Base +pub mut: + name string // Display name of the contact + first_name string + last_name string + nickname string + email []ContactEmail // Multiple email addresses with labels + phone []ContactPhone // Multiple phone numbers with labels + address []ContactAddress // Multiple addresses with labels + company string + job_title string + notes string + birthday ourtime.OurTime + website []string + social_profiles []SocialProfile + photo string // Path or URL to contact photo + groups []u32 // IDs of groups this contact belongs to + custom_fields []CustomField // User-defined fields +} + +// ContactEmail represents an email address with a label +pub struct ContactEmail { +pub mut: + email string + label string // Home, Work, Other, etc. + primary bool +} + +// ContactPhone represents a phone number with a label +pub struct ContactPhone { +pub mut: + number string + label string // Mobile, Home, Work, etc. + primary bool +} + +// ContactAddress represents a physical address with a label +pub struct ContactAddress { +pub mut: + street string + city string + state string + postal_code string + country string + label string // Home, Work, Other, etc. + primary bool +} + +// SocialProfile represents a social media profile +pub struct SocialProfile { +pub mut: + platform string // Facebook, Twitter, LinkedIn, etc. + username string + url string +} + +// CustomField represents a user-defined field +pub struct CustomField { +pub mut: + label string + value string +} + +// ContactGroup represents a group of contacts +pub struct ContactGroup { + base.Base +pub mut: + name string + description string + contacts []u32 // IDs of contacts in this group + owner_id u32 // User who owns this group + shared_with []u32 // Users this group is shared with +} +``` + +## Integration Points + +The MCC system integrates with the existing system in the following ways: + +1. **User Integration**: + - Uses `circle.User` as the primary user model + - The `biz.User` model has been deprecated and should not be used + +2. **Cross-Component Integration**: + - Calendar events can reference contacts as attendees + - Emails can reference calendar events (for invitations) + - Contacts can be used in email addressing + +3. **Base Integration**: + - All models extend the `base.Base` struct for common fields + - Consistent ID and timestamp handling + +## System Architecture + +``` ++----------------+ +----------------+ +----------------+ +| | | | | | +| Mail System |<----->| User System |<----->| Contact System | +| | | | | | ++----------------+ +----------------+ +----------------+ + ^ ^ ^ + | | | + v v v ++----------------+ +----------------+ +----------------+ +| | | | | | +| Calendar System|<----->| Base System |<----->| Group System | +| | | | | | ++----------------+ +----------------+ +----------------+ +``` + +This specification provides a comprehensive data model for creating a self-hosted alternative to Google's Mail, Calendar, and Contacts services, with a focus on data ownership and control. \ No newline at end of file diff --git a/specs/models/mcc/calendar.v b/specs/models/mcc/calendar.v index 794ebcf..e91f257 100644 --- a/specs/models/mcc/calendar.v +++ b/specs/models/mcc/calendar.v @@ -3,10 +3,67 @@ import base import freeflowuniverse.herolib.data.ourtime +// EventStatus represents the status of a calendar event +pub enum EventStatus { + confirmed + cancelled + tentative +} + +// EventColor represents the color categorization of a calendar event +pub enum EventColor { + red + blue + green + yellow + purple + orange + cyan + magenta + gray + custom // For custom color values +} + +// EventVisibility represents the visibility setting of a calendar event +pub enum EventVisibility { + public + private + confidential +} + +// AttendeeResponse represents an attendee's response to an event invitation +pub enum AttendeeResponse { + accepted + declined + tentative + needs_action +} + +// Calendar represents a collection of events +pub struct Calendar { + base.Base +pub mut: + name string // Name of the calendar + description string // Description of the calendar + color string // Color for the calendar + owner_id u32 // User who owns this calendar + timezone string // Default timezone for this calendar + visibility string // Public, private, etc. + shared_with []CalendarShare // Users this calendar is shared with +} + +// CalendarShare represents calendar sharing permissions +pub struct CalendarShare { +pub mut: + user_id u32 // User ID this calendar is shared with + permission string // Read, write, owner, etc. +} + // CalendarEvent represents a calendar event with all its properties pub struct CalendarEvent { base.Base pub mut: + calendar_id u32 // ID of the calendar this event belongs to title string // Event title description string // Event details location string // Event location @@ -14,9 +71,38 @@ pub mut: end_time ourtime.OurTime // End time all_day bool // True if it's an all-day event recurrence string // RFC 5545 Recurrence Rule (e.g., "FREQ=DAILY;COUNT=10") - attendees []u32 // List of contact id's + attendees []Attendee // List of attendees organizer u32 // The user (see circle) who created the event - status string // "CONFIRMED", "CANCELLED", "TENTATIVE" //TODO: make enum - color string // User-friendly color categorization, e.g., "red", "blue" //TODO: make enum - reminder []ourtime.OurTime // Reminder time before the event + status EventStatus // Status of the event + color EventColor // User-friendly color categorization + reminders []Reminder // Reminders for this event + timezone string // Timezone for this specific event + visibility EventVisibility // Visibility setting for the event + attachments []Attachment // Attachments for this event +} + +// Reminder represents a reminder for an event +pub struct Reminder { +pub mut: + event_id u32 // Event this reminder is for + time ourtime.OurTime // When to send the reminder + method string // How to deliver the reminder (email, notification, etc.) +} + +// Attendee represents an attendee of an event +pub struct Attendee { +pub mut: + contact_id u32 // User ID of the attendee + response AttendeeResponse // Attendee's response to the event invitation + optional bool // Whether attendance is optional + comment string // Attendee's comment +} + +// Attachment represents an attachment for a calendar event +pub struct Attachment { +pub mut: + filename string + content_type string + hash string // Hash of the attachment data + size u32 // Size in bytes } diff --git a/specs/models/mcc/contacts.v b/specs/models/mcc/contacts.v index 4cb3af6..43e8f08 100644 --- a/specs/models/mcc/contacts.v +++ b/specs/models/mcc/contacts.v @@ -1,16 +1,111 @@ module biz import base -// import freeflowuniverse.herolib.data.ourtime +import freeflowuniverse.herolib.data.ourtime +// ContactLabelType represents the type of label for contact information +pub enum ContactLabelType { + home + work + mobile + other + main + personal + business + school + custom // For user-defined labels +} +// SocialPlatformType represents the type of social media platform +pub enum SocialPlatformType { + facebook + twitter + linkedin + instagram + github + youtube + tiktok + reddit + pinterest + snapchat + whatsapp + telegram + discord + mastodon + other +} + +// Contact represents a contact with all their information pub struct Contact { base.Base pub mut: - name string // name of the contact as we use in this circle - first_name string - last_name string - email []string - tel []string + name string // Display name of the contact + first_name string + last_name string + nickname string + email []ContactEmail // Multiple email addresses with labels + phone []ContactPhone // Multiple phone numbers with labels + address []ContactAddress // Multiple addresses with labels + company string + job_title string + notes string + birthday ourtime.OurTime + website []string + social_profiles []SocialProfile + photo u32 // link to the attachment in the circle + custom_fields []CustomField // User-defined fields } +// ContactEmail represents an email address with a label +pub struct ContactEmail { +pub mut: + email string + label ContactLabelType // Type of email address + primary bool +} + +// ContactPhone represents a phone number with a label +pub struct ContactPhone { +pub mut: + number string + label ContactLabelType // Type of phone number + primary bool +} + +// ContactAddress represents a physical address with a label +pub struct ContactAddress { +pub mut: + street string + city string + state string + postal_code string + country string + label ContactLabelType // Type of address + primary bool +} + +// SocialProfile represents a social media profile +pub struct SocialProfile { +pub mut: + platform SocialPlatformType // Type of social media platform + username string + url string +} + +// CustomField represents a user-defined field +pub struct CustomField { +pub mut: + label string + value string +} + +// ContactGroup represents a group of contacts +pub struct ContactGroup { + base.Base +pub mut: + name string + description string + contacts []u32 // IDs of contacts in this group + owner_id u32 // User who owns this group + shared_with []u32 // Users this group is shared with +} diff --git a/specs/models/mcc/message.v b/specs/models/mcc/message.v index d7b4926..d243baf 100644 --- a/specs/models/mcc/message.v +++ b/specs/models/mcc/message.v @@ -3,22 +3,29 @@ import base import freeflowuniverse.herolib.data.ourtime -// our attempt to make a message object which can be used for email as well as chat +// MessagePriority represents the priority level of a message +pub enum MessagePriority { + low + normal + high +} + +// Message represents an email message that can be used for email as well as chat pub struct Message { base.Base // Base struct for common fields pub mut: // Database ID - id u32 // Database ID (assigned by DBHandler) - message_id string // Unique identifier for the email - folder string // The folder this email belongs to (inbox, sent, drafts, etc.) - message string // The email body content - attachments []Attachment // Any file attachments - send_time ourtime.OurTime - - date i64 // Unix timestamp when the email was sent/received - size u32 // Size of the message in bytes - read bool // Whether the email has been read - flagged bool // Whether the email has been flagged/starred + conversation_id string // ID for grouping messages in the same thread + folder string // The folder this email belongs to (inbox, sent, drafts, etc.) + labels []u16 //from circle config called message (config with name message) + message string // The email body content + attachments []u32// Any file attachment, is in circle + send_time ourtime.OurTime + scheduled_send ourtime.OurTime // Time to send if scheduled + size u32 // Size of the message in bytes + read bool // Whether the email has been read + flagged bool // Whether the email has been flagged/starred + priority MessagePriority // Priority level // Header information subject string @@ -28,13 +35,6 @@ pub mut: to []u32 cc []u32 bcc []u32 - in_reply_to u32 -} - -// Attachment represents an email attachment -pub struct Attachment { -pub mut: - filename string - content_type string - hash string // Hash of the attachment data + in_reply_to u32 + draft bool // Whether this is a draft message }