...
This commit is contained in:
@@ -80,7 +80,31 @@ pub fn (self CalendarEvent) type_name() string {
|
|||||||
return 'calendar_event'
|
return 'calendar_event'
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self CalendarEvent) dump(mut e &encoder.Encoder) ! {
|
// return example rpc call and result for each methodname
|
||||||
|
pub fn (self CalendarEvent) example(methodname string) (string, string) {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return '{"calendar_event": {"title": "Team Meeting", "start_time": "2025-01-01T10:00:00Z", "end_time": "2025-01-01T11:00:00Z", "location": "Office", "attendees": [], "fs_items": [], "calendar_id": 1, "status": "published", "is_all_day": false, "is_recurring": false, "recurrence": [], "reminder_mins": [15], "color": "#0000FF", "timezone": "UTC"}}', '1'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return '{"id": 1}', '{"title": "Team Meeting", "start_time": "2025-01-01T10:00:00Z", "end_time": "2025-01-01T11:00:00Z", "location": "Office", "attendees": [], "fs_items": [], "calendar_id": 1, "status": "published", "is_all_day": false, "is_recurring": false, "recurrence": [], "reminder_mins": [15], "color": "#0000FF", "timezone": "UTC"}'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return '{}', '[{"title": "Team Meeting", "start_time": "2025-01-01T10:00:00Z", "end_time": "2025-01-01T11:00:00Z", "location": "Office", "attendees": [], "fs_items": [], "calendar_id": 1, "status": "published", "is_all_day": false, "is_recurring": false, "recurrence": [], "reminder_mins": [15], "color": "#0000FF", "timezone": "UTC"}]'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '{}', '{}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (self CalendarEvent) dump(mut e encoder.Encoder) ! {
|
||||||
e.add_string(self.title)
|
e.add_string(self.title)
|
||||||
e.add_i64(self.start_time)
|
e.add_i64(self.start_time)
|
||||||
e.add_i64(self.end_time)
|
e.add_i64(self.end_time)
|
||||||
@@ -108,7 +132,7 @@ pub fn (self CalendarEvent) dump(mut e &encoder.Encoder) ! {
|
|||||||
e.add_string(self.timezone)
|
e.add_string(self.timezone)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DBCalendarEvent) load(mut o CalendarEvent, mut e &encoder.Decoder) ! {
|
fn (mut self DBCalendarEvent) load(mut o CalendarEvent, mut e encoder.Decoder) ! {
|
||||||
o.title = e.get_string()!
|
o.title = e.get_string()!
|
||||||
o.start_time = e.get_i64()!
|
o.start_time = e.get_i64()!
|
||||||
o.end_time = e.get_i64()!
|
o.end_time = e.get_i64()!
|
||||||
@@ -116,7 +140,7 @@ fn (mut self DBCalendarEvent) load(mut o CalendarEvent, mut e &encoder.Decoder)
|
|||||||
o.attendees = e.get_list_u32()!
|
o.attendees = e.get_list_u32()!
|
||||||
o.fs_items = e.get_list_u32()!
|
o.fs_items = e.get_list_u32()!
|
||||||
o.calendar_id = e.get_u32()!
|
o.calendar_id = e.get_u32()!
|
||||||
o.status = unsafe { EventStatus(e.get_u8()!) } //TODO: is there no better way?
|
o.status = unsafe { EventStatus(e.get_u8()!) } // TODO: is there no better way?
|
||||||
o.is_all_day = e.get_bool()!
|
o.is_all_day = e.get_bool()!
|
||||||
o.is_recurring = e.get_bool()!
|
o.is_recurring = e.get_bool()!
|
||||||
|
|
||||||
|
|||||||
@@ -30,13 +30,37 @@ pub fn (self ChatGroup) type_name() string {
|
|||||||
return 'chat_group'
|
return 'chat_group'
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self ChatGroup) dump(mut e &encoder.Encoder) ! {
|
// return example rpc call and result for each methodname
|
||||||
|
pub fn (self ChatGroup) example(methodname string) (string, string) {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return '{"chat_group": {"name": "General Chat", "description": "A general chat group", "chat_type": "public_channel", "last_activity": 1678886400, "is_archived": false}}', '1'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return '{"id": 1}', '{"name": "General Chat", "description": "A general chat group", "chat_type": "public_channel", "last_activity": 1678886400, "is_archived": false}'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return '{}', '[{"name": "General Chat", "description": "A general chat group", "chat_type": "public_channel", "last_activity": 1678886400, "is_archived": false}]'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '{}', '{}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (self ChatGroup) dump(mut e encoder.Encoder) ! {
|
||||||
e.add_u8(u8(self.chat_type))
|
e.add_u8(u8(self.chat_type))
|
||||||
e.add_i64(self.last_activity)
|
e.add_i64(self.last_activity)
|
||||||
e.add_bool(self.is_archived)
|
e.add_bool(self.is_archived)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DBChatGroup) load(mut o ChatGroup, mut e &encoder.Decoder) ! {
|
fn (mut self DBChatGroup) load(mut o ChatGroup, mut e encoder.Decoder) ! {
|
||||||
o.chat_type = unsafe { ChatType(e.get_u8()!) }
|
o.chat_type = unsafe { ChatType(e.get_u8()!) }
|
||||||
o.last_activity = e.get_i64()!
|
o.last_activity = e.get_i64()!
|
||||||
o.is_archived = e.get_bool()!
|
o.is_archived = e.get_bool()!
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ pub struct ChatMessage {
|
|||||||
db.Base
|
db.Base
|
||||||
pub mut:
|
pub mut:
|
||||||
content string
|
content string
|
||||||
chat_group_id u32 // Associated chat group
|
chat_group_id u32 // Associated chat group
|
||||||
sender_id u32 // User ID of sender
|
sender_id u32 // User ID of sender
|
||||||
parent_messages []MessageLink // Referenced/replied messages
|
parent_messages []MessageLink // Referenced/replied messages
|
||||||
fs_files []u32 // IDs of linked files
|
fs_files []u32 // IDs of linked files
|
||||||
message_type MessageType
|
message_type MessageType
|
||||||
status MessageStatus
|
status MessageStatus
|
||||||
reactions []MessageReaction
|
reactions []MessageReaction
|
||||||
@@ -67,7 +67,31 @@ pub fn (self ChatMessage) type_name() string {
|
|||||||
return 'chat_message'
|
return 'chat_message'
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self ChatMessage) dump(mut e &encoder.Encoder) ! {
|
// return example rpc call and result for each methodname
|
||||||
|
pub fn (self ChatMessage) example(methodname string) (string, string) {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return '{"chat_message": {"content": "Hello, everyone!", "chat_group_id": 1, "sender_id": 1, "parent_messages": [], "fs_files": [], "message_type": "text", "status": "sent", "reactions": [], "mentions": []}}', '1'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return '{"id": 1}', '{"content": "Hello, everyone!", "chat_group_id": 1, "sender_id": 1, "parent_messages": [], "fs_files": [], "message_type": "text", "status": "sent", "reactions": [], "mentions": []}'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return '{}', '[{"content": "Hello, everyone!", "chat_group_id": 1, "sender_id": 1, "parent_messages": [], "fs_files": [], "message_type": "text", "status": "sent", "reactions": [], "mentions": []}]'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '{}', '{}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (self ChatMessage) dump(mut e encoder.Encoder) ! {
|
||||||
e.add_string(self.content)
|
e.add_string(self.content)
|
||||||
e.add_u32(self.chat_group_id)
|
e.add_u32(self.chat_group_id)
|
||||||
e.add_u32(self.sender_id)
|
e.add_u32(self.sender_id)
|
||||||
@@ -94,7 +118,7 @@ pub fn (self ChatMessage) dump(mut e &encoder.Encoder) ! {
|
|||||||
e.add_list_u32(self.mentions)
|
e.add_list_u32(self.mentions)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DBChatMessage) load(mut o ChatMessage, mut e &encoder.Decoder) ! {
|
fn (mut self DBChatMessage) load(mut o ChatMessage, mut e encoder.Decoder) ! {
|
||||||
o.content = e.get_string()!
|
o.content = e.get_string()!
|
||||||
o.chat_group_id = e.get_u32()!
|
o.chat_group_id = e.get_u32()!
|
||||||
o.sender_id = e.get_u32()!
|
o.sender_id = e.get_u32()!
|
||||||
@@ -137,20 +161,20 @@ fn (mut self DBChatMessage) load(mut o ChatMessage, mut e &encoder.Decoder) ! {
|
|||||||
@[params]
|
@[params]
|
||||||
pub struct ChatMessageArg {
|
pub struct ChatMessageArg {
|
||||||
pub mut:
|
pub mut:
|
||||||
name string
|
name string
|
||||||
description string
|
description string
|
||||||
content string
|
content string
|
||||||
chat_group_id u32
|
chat_group_id u32
|
||||||
sender_id u32
|
sender_id u32
|
||||||
parent_messages []MessageLink
|
parent_messages []MessageLink
|
||||||
fs_files []u32
|
fs_files []u32
|
||||||
message_type MessageType
|
message_type MessageType
|
||||||
status MessageStatus
|
status MessageStatus
|
||||||
reactions []MessageReaction
|
reactions []MessageReaction
|
||||||
mentions []u32
|
mentions []u32
|
||||||
securitypolicy u32
|
securitypolicy u32
|
||||||
tags []string
|
tags []string
|
||||||
comments []db.CommentArg
|
comments []db.CommentArg
|
||||||
}
|
}
|
||||||
|
|
||||||
// get new chat message, not from the DB
|
// get new chat message, not from the DB
|
||||||
|
|||||||
@@ -26,13 +26,37 @@ pub fn (self Comment) type_name() string {
|
|||||||
return 'comments'
|
return 'comments'
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self Comment) dump(mut e &encoder.Encoder) ! {
|
// return example rpc call and result for each methodname
|
||||||
|
pub fn (self Comment) example(methodname string) (string, string) {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return '{"comment": {"comment": "This is a test comment.", "parent": 0, "author": 1}}', '1'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return '{"id": 1}', '{"comment": "This is a test comment.", "parent": 0, "author": 1}'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return '{}', '[{"comment": "This is a test comment.", "parent": 0, "author": 1}]'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '{}', '{}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (self Comment) dump(mut e encoder.Encoder) ! {
|
||||||
e.add_string(self.comment)
|
e.add_string(self.comment)
|
||||||
e.add_u32(self.parent)
|
e.add_u32(self.parent)
|
||||||
e.add_u32(self.author)
|
e.add_u32(self.author)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DBComments) load(mut o Comment, mut e &encoder.Decoder) ! {
|
fn (mut self DBComments) load(mut o Comment, mut e encoder.Decoder) ! {
|
||||||
o.comment = e.get_string()!
|
o.comment = e.get_string()!
|
||||||
o.parent = e.get_u32()!
|
o.parent = e.get_u32()!
|
||||||
o.author = e.get_u32()!
|
o.author = e.get_u32()!
|
||||||
|
|||||||
@@ -33,7 +33,31 @@ pub fn (self Group) type_name() string {
|
|||||||
return 'group'
|
return 'group'
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self Group) dump(mut e &encoder.Encoder) ! {
|
// return example rpc call and result for each methodname
|
||||||
|
pub fn (self Group) example(methodname string) (string, string) {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return '{"group": {"name": "Admins", "description": "Administrators group", "members": [], "subgroups": [], "parent_group": 0, "is_public": false}}', '1'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return '{"id": 1}', '{"name": "Admins", "description": "Administrators group", "members": [], "subgroups": [], "parent_group": 0, "is_public": false}'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return '{}', '[{"name": "Admins", "description": "Administrators group", "members": [], "subgroups": [], "parent_group": 0, "is_public": false}]'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '{}', '{}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (self Group) dump(mut e encoder.Encoder) ! {
|
||||||
e.add_u16(u16(self.members.len))
|
e.add_u16(u16(self.members.len))
|
||||||
for member in self.members {
|
for member in self.members {
|
||||||
e.add_u32(member.user_id)
|
e.add_u32(member.user_id)
|
||||||
@@ -45,14 +69,14 @@ pub fn (self Group) dump(mut e &encoder.Encoder) ! {
|
|||||||
e.add_bool(self.is_public)
|
e.add_bool(self.is_public)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DBGroup) load(mut o Group, mut e &encoder.Decoder) ! {
|
fn (mut self DBGroup) load(mut o Group, mut e encoder.Decoder) ! {
|
||||||
members_len := e.get_u16()!
|
members_len := e.get_u16()!
|
||||||
mut members := []GroupMember{}
|
mut members := []GroupMember{}
|
||||||
for _ in 0 .. members_len {
|
for _ in 0 .. members_len {
|
||||||
user_id := e.get_u32()!
|
user_id := e.get_u32()!
|
||||||
role := unsafe { GroupRole(e.get_u8()!) }
|
role := unsafe { GroupRole(e.get_u8()!) }
|
||||||
joined_at := e.get_i64()!
|
joined_at := e.get_i64()!
|
||||||
|
|
||||||
members << GroupMember{
|
members << GroupMember{
|
||||||
user_id: user_id
|
user_id: user_id
|
||||||
role: role
|
role: role
|
||||||
@@ -60,7 +84,7 @@ fn (mut self DBGroup) load(mut o Group, mut e &encoder.Decoder) ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
o.members = members
|
o.members = members
|
||||||
|
|
||||||
o.subgroups = e.get_list_u32()!
|
o.subgroups = e.get_list_u32()!
|
||||||
o.parent_group = e.get_u32()!
|
o.parent_group = e.get_u32()!
|
||||||
o.is_public = e.get_bool()!
|
o.is_public = e.get_bool()!
|
||||||
@@ -90,12 +114,12 @@ pub fn (mut self DBGroup) new(args GroupArg) !Group {
|
|||||||
parent_group: args.parent_group
|
parent_group: args.parent_group
|
||||||
is_public: args.is_public
|
is_public: args.is_public
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set base fields
|
// Set base fields
|
||||||
o.name = args.name
|
o.name = args.name
|
||||||
o.description = args.description
|
o.description = args.description
|
||||||
o.updated_at = ourtime.now().unix()
|
o.updated_at = ourtime.now().unix()
|
||||||
|
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,5 +155,4 @@ pub fn (mut self Group) add_member(user_id u32, role GroupRole) {
|
|||||||
self.members << member
|
self.members << member
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CUSTOM FEATURES FOR GROUP
|
||||||
//CUSTOM FEATURES FOR GROUP
|
|
||||||
|
|||||||
@@ -9,18 +9,18 @@ import freeflowuniverse.herolib.hero.db
|
|||||||
pub struct Project {
|
pub struct Project {
|
||||||
db.Base
|
db.Base
|
||||||
pub mut:
|
pub mut:
|
||||||
swimlanes []Swimlane
|
swimlanes []Swimlane
|
||||||
milestones []Milestone
|
milestones []Milestone
|
||||||
issues []string // IDs of project issues
|
issues []string // IDs of project issues
|
||||||
fs_files []u32 // IDs of linked files or dirs
|
fs_files []u32 // IDs of linked files or dirs
|
||||||
status ProjectStatus
|
status ProjectStatus
|
||||||
start_date i64
|
start_date i64
|
||||||
end_date i64
|
end_date i64
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Swimlane {
|
pub struct Swimlane {
|
||||||
pub mut:
|
pub mut:
|
||||||
name string //allways to to_lower and trim_space
|
name string // allways to to_lower and trim_space
|
||||||
description string
|
description string
|
||||||
order int
|
order int
|
||||||
color string
|
color string
|
||||||
@@ -29,7 +29,7 @@ pub mut:
|
|||||||
|
|
||||||
pub struct Milestone {
|
pub struct Milestone {
|
||||||
pub mut:
|
pub mut:
|
||||||
name string //allways to to_lower and trim_space
|
name string // allways to to_lower and trim_space
|
||||||
description string
|
description string
|
||||||
due_date i64
|
due_date i64
|
||||||
completed bool
|
completed bool
|
||||||
@@ -53,7 +53,31 @@ pub fn (self Project) type_name() string {
|
|||||||
return 'project'
|
return 'project'
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self Project) dump(mut e &encoder.Encoder) ! {
|
// return example rpc call and result for each methodname
|
||||||
|
pub fn (self Project) example(methodname string) (string, string) {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return '{"project": {"name": "My Project", "description": "A project to track tasks", "swimlanes": [], "milestones": [], "issues": [], "fs_files": [], "status": "active", "start_date": "2025-01-01T00:00:00Z", "end_date": "2025-12-31T23:59:59Z"}}', '1'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return '{"id": 1}', '{"name": "My Project", "description": "A project to track tasks", "swimlanes": [], "milestones": [], "issues": [], "fs_files": [], "status": "active", "start_date": "2025-01-01T00:00:00Z", "end_date": "2025-12-31T23:59:59Z"}'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return '{}', '[{"name": "My Project", "description": "A project to track tasks", "swimlanes": [], "milestones": [], "issues": [], "fs_files": [], "status": "active", "start_date": "2025-01-01T00:00:00Z", "end_date": "2025-12-31T23:59:59Z"}]'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '{}', '{}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (self Project) dump(mut e encoder.Encoder) ! {
|
||||||
e.add_u16(u16(self.swimlanes.len))
|
e.add_u16(u16(self.swimlanes.len))
|
||||||
for swimlane in self.swimlanes {
|
for swimlane in self.swimlanes {
|
||||||
e.add_string(swimlane.name)
|
e.add_string(swimlane.name)
|
||||||
@@ -62,7 +86,7 @@ pub fn (self Project) dump(mut e &encoder.Encoder) ! {
|
|||||||
e.add_string(swimlane.color)
|
e.add_string(swimlane.color)
|
||||||
e.add_bool(swimlane.is_done)
|
e.add_bool(swimlane.is_done)
|
||||||
}
|
}
|
||||||
|
|
||||||
e.add_u16(u16(self.milestones.len))
|
e.add_u16(u16(self.milestones.len))
|
||||||
for milestone in self.milestones {
|
for milestone in self.milestones {
|
||||||
e.add_string(milestone.name)
|
e.add_string(milestone.name)
|
||||||
@@ -71,7 +95,7 @@ pub fn (self Project) dump(mut e &encoder.Encoder) ! {
|
|||||||
e.add_bool(milestone.completed)
|
e.add_bool(milestone.completed)
|
||||||
e.add_list_u32(milestone.issues)
|
e.add_list_u32(milestone.issues)
|
||||||
}
|
}
|
||||||
|
|
||||||
e.add_list_string(self.issues)
|
e.add_list_string(self.issues)
|
||||||
e.add_list_u32(self.fs_files)
|
e.add_list_u32(self.fs_files)
|
||||||
e.add_u8(u8(self.status))
|
e.add_u8(u8(self.status))
|
||||||
@@ -79,7 +103,7 @@ pub fn (self Project) dump(mut e &encoder.Encoder) ! {
|
|||||||
e.add_i64(self.end_date)
|
e.add_i64(self.end_date)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DBProject) load(mut o Project, mut e &encoder.Decoder) ! {
|
fn (mut self DBProject) load(mut o Project, mut e encoder.Decoder) ! {
|
||||||
swimlanes_len := e.get_u16()!
|
swimlanes_len := e.get_u16()!
|
||||||
mut swimlanes := []Swimlane{}
|
mut swimlanes := []Swimlane{}
|
||||||
for _ in 0 .. swimlanes_len {
|
for _ in 0 .. swimlanes_len {
|
||||||
@@ -88,7 +112,7 @@ fn (mut self DBProject) load(mut o Project, mut e &encoder.Decoder) ! {
|
|||||||
order := e.get_int()!
|
order := e.get_int()!
|
||||||
color := e.get_string()!
|
color := e.get_string()!
|
||||||
is_done := e.get_bool()!
|
is_done := e.get_bool()!
|
||||||
|
|
||||||
swimlanes << Swimlane{
|
swimlanes << Swimlane{
|
||||||
name: name
|
name: name
|
||||||
description: description
|
description: description
|
||||||
@@ -98,7 +122,7 @@ fn (mut self DBProject) load(mut o Project, mut e &encoder.Decoder) ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
o.swimlanes = swimlanes
|
o.swimlanes = swimlanes
|
||||||
|
|
||||||
milestones_len := e.get_u16()!
|
milestones_len := e.get_u16()!
|
||||||
mut milestones := []Milestone{}
|
mut milestones := []Milestone{}
|
||||||
for _ in 0 .. milestones_len {
|
for _ in 0 .. milestones_len {
|
||||||
@@ -107,7 +131,7 @@ fn (mut self DBProject) load(mut o Project, mut e &encoder.Decoder) ! {
|
|||||||
due_date := e.get_i64()!
|
due_date := e.get_i64()!
|
||||||
completed := e.get_bool()!
|
completed := e.get_bool()!
|
||||||
issues := e.get_list_u32()!
|
issues := e.get_list_u32()!
|
||||||
|
|
||||||
milestones << Milestone{
|
milestones << Milestone{
|
||||||
name: name
|
name: name
|
||||||
description: description
|
description: description
|
||||||
@@ -117,7 +141,7 @@ fn (mut self DBProject) load(mut o Project, mut e &encoder.Decoder) ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
o.milestones = milestones
|
o.milestones = milestones
|
||||||
|
|
||||||
o.issues = e.get_list_string()!
|
o.issues = e.get_list_string()!
|
||||||
o.fs_files = e.get_list_u32()!
|
o.fs_files = e.get_list_u32()!
|
||||||
o.status = unsafe { ProjectStatus(e.get_u8()!) }
|
o.status = unsafe { ProjectStatus(e.get_u8()!) }
|
||||||
@@ -128,15 +152,15 @@ fn (mut self DBProject) load(mut o Project, mut e &encoder.Decoder) ! {
|
|||||||
@[params]
|
@[params]
|
||||||
pub struct ProjectArg {
|
pub struct ProjectArg {
|
||||||
pub mut:
|
pub mut:
|
||||||
name string
|
name string
|
||||||
description string
|
description string
|
||||||
swimlanes []Swimlane
|
swimlanes []Swimlane
|
||||||
milestones []Milestone
|
milestones []Milestone
|
||||||
issues []string
|
issues []string
|
||||||
fs_files []u32
|
fs_files []u32
|
||||||
status ProjectStatus
|
status ProjectStatus
|
||||||
start_date string // Use ourtime module to convert to epoch
|
start_date string // Use ourtime module to convert to epoch
|
||||||
end_date string // Use ourtime module to convert to epoch
|
end_date string // Use ourtime module to convert to epoch
|
||||||
securitypolicy u32
|
securitypolicy u32
|
||||||
tags []string
|
tags []string
|
||||||
comments []db.CommentArg
|
comments []db.CommentArg
|
||||||
@@ -145,13 +169,13 @@ pub mut:
|
|||||||
// get new project, not from the DB
|
// get new project, not from the DB
|
||||||
pub fn (mut self DBProject) new(args ProjectArg) !Project {
|
pub fn (mut self DBProject) new(args ProjectArg) !Project {
|
||||||
mut o := Project{
|
mut o := Project{
|
||||||
swimlanes: args.swimlanes
|
swimlanes: args.swimlanes
|
||||||
milestones: args.milestones
|
milestones: args.milestones
|
||||||
issues: args.issues
|
issues: args.issues
|
||||||
fs_files: args.fs_files
|
fs_files: args.fs_files
|
||||||
status: args.status
|
status: args.status
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set base fields
|
// Set base fields
|
||||||
o.name = args.name
|
o.name = args.name
|
||||||
o.description = args.description
|
o.description = args.description
|
||||||
@@ -159,14 +183,14 @@ pub fn (mut self DBProject) new(args ProjectArg) !Project {
|
|||||||
o.tags = self.db.tags_get(args.tags)!
|
o.tags = self.db.tags_get(args.tags)!
|
||||||
o.comments = self.db.comments_get(args.comments)!
|
o.comments = self.db.comments_get(args.comments)!
|
||||||
o.updated_at = ourtime.now().unix()
|
o.updated_at = ourtime.now().unix()
|
||||||
|
|
||||||
// Convert string dates to Unix timestamps
|
// Convert string dates to Unix timestamps
|
||||||
mut start_time_obj := ourtime.new(args.start_date)!
|
mut start_time_obj := ourtime.new(args.start_date)!
|
||||||
o.start_date = start_time_obj.unix()
|
o.start_date = start_time_obj.unix()
|
||||||
|
|
||||||
mut end_time_obj := ourtime.new(args.end_date)!
|
mut end_time_obj := ourtime.new(args.end_date)!
|
||||||
o.end_date = end_time_obj.unix()
|
o.end_date = end_time_obj.unix()
|
||||||
|
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,20 +9,20 @@ import freeflowuniverse.herolib.hero.db
|
|||||||
pub struct ProjectIssue {
|
pub struct ProjectIssue {
|
||||||
db.Base
|
db.Base
|
||||||
pub mut:
|
pub mut:
|
||||||
title string
|
title string
|
||||||
project_id u32 // Associated project
|
project_id u32 // Associated project
|
||||||
issue_type IssueType
|
issue_type IssueType
|
||||||
priority IssuePriority
|
priority IssuePriority
|
||||||
status IssueStatus
|
status IssueStatus
|
||||||
swimlane string // Current swimlane, is string corresponds to name, need to be to_lower and trim_space
|
swimlane string // Current swimlane, is string corresponds to name, need to be to_lower and trim_space
|
||||||
assignees []u32 // User IDs
|
assignees []u32 // User IDs
|
||||||
reporter u32 // User ID who created the issue
|
reporter u32 // User ID who created the issue
|
||||||
milestone string // Associated milestone, is string corresponds to name, need to be to_lower and trim_space
|
milestone string // Associated milestone, is string corresponds to name, need to be to_lower and trim_space
|
||||||
deadline i64 // Unix timestamp
|
deadline i64 // Unix timestamp
|
||||||
estimate int // Story points or hours
|
estimate int // Story points or hours
|
||||||
fs_files []u32 // IDs of linked files
|
fs_files []u32 // IDs of linked files
|
||||||
parent_id u32 // Parent issue ID (for sub-tasks)
|
parent_id u32 // Parent issue ID (for sub-tasks)
|
||||||
children []u32 // Child issue IDs
|
children []u32 // Child issue IDs
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum IssueType {
|
pub enum IssueType {
|
||||||
@@ -62,7 +62,31 @@ pub fn (self ProjectIssue) type_name() string {
|
|||||||
return 'project_issue'
|
return 'project_issue'
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self ProjectIssue) dump(mut e &encoder.Encoder) ! {
|
// return example rpc call and result for each methodname
|
||||||
|
pub fn (self ProjectIssue) example(methodname string) (string, string) {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return '{"project_issue": {"title": "Implement new feature", "project_id": 1, "issue_type": "story", "priority": "high", "status": "open", "swimlane": "backlog", "assignees": [1], "reporter": 1, "milestone": "sprint 1", "deadline": "2025-03-01T00:00:00Z", "estimate": 8, "fs_files": [], "parent_id": 0, "children": []}}', '1'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return '{"id": 1}', '{"title": "Implement new feature", "project_id": 1, "issue_type": "story", "priority": "high", "status": "open", "swimlane": "backlog", "assignees": [1], "reporter": 1, "milestone": "sprint 1", "deadline": "2025-03-01T00:00:00Z", "estimate": 8, "fs_files": [], "parent_id": 0, "children": []}'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return '{}', '[{"title": "Implement new feature", "project_id": 1, "issue_type": "story", "priority": "high", "status": "open", "swimlane": "backlog", "assignees": [1], "reporter": 1, "milestone": "sprint 1", "deadline": "2025-03-01T00:00:00Z", "estimate": 8, "fs_files": [], "parent_id": 0, "children": []}]'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '{}', '{}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (self ProjectIssue) dump(mut e encoder.Encoder) ! {
|
||||||
e.add_string(self.title)
|
e.add_string(self.title)
|
||||||
e.add_u32(self.project_id)
|
e.add_u32(self.project_id)
|
||||||
e.add_u8(u8(self.issue_type))
|
e.add_u8(u8(self.issue_type))
|
||||||
@@ -79,7 +103,7 @@ pub fn (self ProjectIssue) dump(mut e &encoder.Encoder) ! {
|
|||||||
e.add_list_u32(self.children)
|
e.add_list_u32(self.children)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DBProjectIssue) load(mut o ProjectIssue, mut e &encoder.Decoder) ! {
|
fn (mut self DBProjectIssue) load(mut o ProjectIssue, mut e encoder.Decoder) ! {
|
||||||
o.title = e.get_string()!
|
o.title = e.get_string()!
|
||||||
o.project_id = e.get_u32()!
|
o.project_id = e.get_u32()!
|
||||||
o.issue_type = unsafe { IssueType(e.get_u8()!) }
|
o.issue_type = unsafe { IssueType(e.get_u8()!) }
|
||||||
@@ -99,22 +123,22 @@ fn (mut self DBProjectIssue) load(mut o ProjectIssue, mut e &encoder.Decoder) !
|
|||||||
@[params]
|
@[params]
|
||||||
pub struct ProjectIssueArg {
|
pub struct ProjectIssueArg {
|
||||||
pub mut:
|
pub mut:
|
||||||
name string
|
name string
|
||||||
description string
|
description string
|
||||||
title string
|
title string
|
||||||
project_id u32
|
project_id u32
|
||||||
issue_type IssueType
|
issue_type IssueType
|
||||||
priority IssuePriority
|
priority IssuePriority
|
||||||
status IssueStatus
|
status IssueStatus
|
||||||
swimlane string
|
swimlane string
|
||||||
assignees []u32
|
assignees []u32
|
||||||
reporter u32
|
reporter u32
|
||||||
milestone string
|
milestone string
|
||||||
deadline string // Use ourtime module to convert to epoch
|
deadline string // Use ourtime module to convert to epoch
|
||||||
estimate int
|
estimate int
|
||||||
fs_files []u32
|
fs_files []u32
|
||||||
parent_id u32
|
parent_id u32
|
||||||
children []u32
|
children []u32
|
||||||
securitypolicy u32
|
securitypolicy u32
|
||||||
tags []string
|
tags []string
|
||||||
comments []db.CommentArg
|
comments []db.CommentArg
|
||||||
@@ -145,10 +169,10 @@ pub fn (mut self DBProjectIssue) new(args ProjectIssueArg) !ProjectIssue {
|
|||||||
if !db_project.exist(args.project_id)! {
|
if !db_project.exist(args.project_id)! {
|
||||||
return error('Project with ID ${args.project_id} does not exist')
|
return error('Project with ID ${args.project_id} does not exist')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the project to validate swimlane and milestone
|
// Get the project to validate swimlane and milestone
|
||||||
project_obj := db_project.get(args.project_id)!
|
project_obj := db_project.get(args.project_id)!
|
||||||
|
|
||||||
// Validate swimlane exists in the project
|
// Validate swimlane exists in the project
|
||||||
mut swimlane_exists := false
|
mut swimlane_exists := false
|
||||||
for swimlane in project_obj.swimlanes {
|
for swimlane in project_obj.swimlanes {
|
||||||
@@ -160,7 +184,7 @@ pub fn (mut self DBProjectIssue) new(args ProjectIssueArg) !ProjectIssue {
|
|||||||
if !swimlane_exists {
|
if !swimlane_exists {
|
||||||
return error('Swimlane "${args.swimlane}" does not exist in project "${project_obj.name}"')
|
return error('Swimlane "${args.swimlane}" does not exist in project "${project_obj.name}"')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate milestone exists in the project
|
// Validate milestone exists in the project
|
||||||
mut milestone_exists := false
|
mut milestone_exists := false
|
||||||
for milestone in project_obj.milestones {
|
for milestone in project_obj.milestones {
|
||||||
@@ -172,7 +196,7 @@ pub fn (mut self DBProjectIssue) new(args ProjectIssueArg) !ProjectIssue {
|
|||||||
if !milestone_exists {
|
if !milestone_exists {
|
||||||
return error('Milestone "${args.milestone}" does not exist in project "${project_obj.name}"')
|
return error('Milestone "${args.milestone}" does not exist in project "${project_obj.name}"')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set base fields
|
// Set base fields
|
||||||
o.name = args.name
|
o.name = args.name
|
||||||
o.description = args.description
|
o.description = args.description
|
||||||
@@ -180,11 +204,11 @@ pub fn (mut self DBProjectIssue) new(args ProjectIssueArg) !ProjectIssue {
|
|||||||
o.tags = self.db.tags_get(args.tags)!
|
o.tags = self.db.tags_get(args.tags)!
|
||||||
o.comments = self.db.comments_get(args.comments)!
|
o.comments = self.db.comments_get(args.comments)!
|
||||||
o.updated_at = ourtime.now().unix()
|
o.updated_at = ourtime.now().unix()
|
||||||
|
|
||||||
// Convert deadline string to Unix timestamp
|
// Convert deadline string to Unix timestamp
|
||||||
mut deadline_obj := ourtime.new(args.deadline)!
|
mut deadline_obj := ourtime.new(args.deadline)!
|
||||||
o.deadline = deadline_obj.unix()
|
o.deadline = deadline_obj.unix()
|
||||||
|
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,55 @@ pub fn (self User) type_name() string {
|
|||||||
return 'user'
|
return 'user'
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self User) dump(mut e &encoder.Encoder) ! {
|
// return example rpc call and result for each methodname
|
||||||
|
pub fn (self User) description(methodname string) string {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return 'Create or update a user. Returns the ID of the user.'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return 'Retrieve a user by ID. Returns the user object.'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return 'Delete a user by ID. Returns true if successful.'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return 'Check if a user exists by ID. Returns true or false.'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return 'List all users. Returns an array of user objects.'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 'This is generic method for the root object, TODO fill in, ...'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return example rpc call and result for each methodname
|
||||||
|
pub fn (self User) example(methodname string) (string, string) {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return '{"user": {"name": "John Doe", "description": "A test user", "email": "john.doe@example.com", "public_key": "some_public_key", "phone": "123-456-7890", "address": "123 Main St", "avatar_url": "https://example.com/avatar.jpg", "bio": "Software Engineer", "timezone": "UTC", "status": "active"}}', '1'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return '{"id": 1}', '{"name": "John Doe", "description": "A test user", "email": "john.doe@example.com", "public_key": "some_public_key", "phone": "123-456-7890", "address": "123 Main St", "avatar_url": "https://example.com/avatar.jpg", "bio": "Software Engineer", "timezone": "UTC", "status": "active"}'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return '{}', '[{"name": "John Doe", "description": "A test user", "email": "john.doe@example.com", "public_key": "some_public_key", "phone": "123-456-7890", "address": "123 Main St", "avatar_url": "https://example.com/avatar.jpg", "bio": "Software Engineer", "timezone": "UTC", "status": "active"}]'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '{}', '{}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (self User) dump(mut e encoder.Encoder) ! {
|
||||||
e.add_string(self.email)
|
e.add_string(self.email)
|
||||||
e.add_string(self.public_key)
|
e.add_string(self.public_key)
|
||||||
e.add_string(self.phone)
|
e.add_string(self.phone)
|
||||||
@@ -41,7 +89,7 @@ pub fn (self User) dump(mut e &encoder.Encoder) ! {
|
|||||||
e.add_u8(u8(self.status))
|
e.add_u8(u8(self.status))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DBUser) load(mut o User, mut e &encoder.Decoder) ! {
|
fn (mut self DBUser) load(mut o User, mut e encoder.Decoder) ! {
|
||||||
o.email = e.get_string()!
|
o.email = e.get_string()!
|
||||||
o.public_key = e.get_string()!
|
o.public_key = e.get_string()!
|
||||||
o.phone = e.get_string()!
|
o.phone = e.get_string()!
|
||||||
@@ -55,19 +103,19 @@ fn (mut self DBUser) load(mut o User, mut e &encoder.Decoder) ! {
|
|||||||
@[params]
|
@[params]
|
||||||
pub struct UserArg {
|
pub struct UserArg {
|
||||||
pub mut:
|
pub mut:
|
||||||
name string @[required]
|
name string @[required]
|
||||||
description string
|
description string
|
||||||
email string
|
email string
|
||||||
public_key string // for encryption/signing
|
public_key string // for encryption/signing
|
||||||
phone string
|
phone string
|
||||||
address string
|
address string
|
||||||
avatar_url string
|
avatar_url string
|
||||||
bio string
|
bio string
|
||||||
timezone string
|
timezone string
|
||||||
status UserStatus
|
status UserStatus
|
||||||
securitypolicy u32
|
securitypolicy u32
|
||||||
tags u32
|
tags u32
|
||||||
comments []u32
|
comments []u32
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DBUser {
|
pub struct DBUser {
|
||||||
|
|||||||
Reference in New Issue
Block a user