...
This commit is contained in:
@@ -1,173 +0,0 @@
|
|||||||
module heromodels
|
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.encoder
|
|
||||||
import freeflowuniverse.herolib.data.ourtime
|
|
||||||
import freeflowuniverse.herolib.hero.db
|
|
||||||
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Response, new_error, new_response, new_response_false, new_response_ok, new_response_true, new_response_int }
|
|
||||||
import freeflowuniverse.herolib.hero.user { UserRef }
|
|
||||||
import json
|
|
||||||
@[heap]
|
|
||||||
pub struct Comment {
|
|
||||||
db.Base
|
|
||||||
pub mut:
|
|
||||||
// id u32
|
|
||||||
comment string
|
|
||||||
parent u32 // id of parent comment if any, 0 means none
|
|
||||||
author u32 // links to user
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////TO BE GENERATED BY AI////////////////////////////////
|
|
||||||
///BASIC CRUD FUNCTIONS
|
|
||||||
|
|
||||||
pub struct DBComments {
|
|
||||||
pub mut:
|
|
||||||
db &db.DB @[skip; str: skip]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (self Comment) type_name() string {
|
|
||||||
return 'comments'
|
|
||||||
}
|
|
||||||
|
|
||||||
// return example rpc call and result for each methodname
|
|
||||||
pub fn (self Comment) description(methodname string) string {
|
|
||||||
match methodname {
|
|
||||||
'set' {
|
|
||||||
return 'Create or update a comment. Returns the ID of the comment.'
|
|
||||||
}
|
|
||||||
'get' {
|
|
||||||
return 'Retrieve a comment by ID. Returns the comment object.'
|
|
||||||
}
|
|
||||||
'delete' {
|
|
||||||
return 'Delete a comment by ID. Returns true if successful.'
|
|
||||||
}
|
|
||||||
'exist' {
|
|
||||||
return 'Check if a comment exists by ID. Returns true or false.'
|
|
||||||
}
|
|
||||||
'list' {
|
|
||||||
return 'List all comments. Returns an array of comment 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 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_u32(self.parent)
|
|
||||||
e.add_u32(self.author)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn (mut self DBComments) load(mut o Comment, mut e encoder.Decoder) ! {
|
|
||||||
o.comment = e.get_string()!
|
|
||||||
o.parent = e.get_u32()!
|
|
||||||
o.author = e.get_u32()!
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct CommentArg {
|
|
||||||
pub mut:
|
|
||||||
comment string @[required]
|
|
||||||
parent u32
|
|
||||||
author u32
|
|
||||||
}
|
|
||||||
|
|
||||||
// get new comment, not from the DB
|
|
||||||
pub fn (mut self DBComments) new(args CommentArg) !Comment {
|
|
||||||
mut o := Comment{
|
|
||||||
comment: args.comment
|
|
||||||
parent: args.parent
|
|
||||||
updated_at: ourtime.now().unix()
|
|
||||||
author: args.author
|
|
||||||
}
|
|
||||||
return o
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (mut self DBComments) set(o Comment) !Comment {
|
|
||||||
// Use db set function which returns the object with assigned ID
|
|
||||||
return self.db.set[Comment](o)!
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (mut self DBComments) delete(id u32) ! {
|
|
||||||
self.db.delete[Comment](id)!
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (mut self DBComments) exist(id u32) !bool {
|
|
||||||
return self.db.exists[Comment](id)!
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (mut self DBComments) get(id u32) !Comment {
|
|
||||||
mut o, data := self.db.get_data[Comment](id)!
|
|
||||||
mut e_decoder := encoder.decoder_new(data)
|
|
||||||
self.load(mut o, mut e_decoder)!
|
|
||||||
return o
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (mut self DBComments) list() ![]Comment {
|
|
||||||
return self.db.list[Comment]()!.map(self.get(it)!)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pub fn comment_handle(mut f ModelsFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response {
|
|
||||||
match method {
|
|
||||||
'get' {
|
|
||||||
id := db.decode_u32(params)!
|
|
||||||
res := f.comments.get(id)!
|
|
||||||
return new_response(rpcid, json.encode(res))
|
|
||||||
}
|
|
||||||
'set' {
|
|
||||||
mut o := db.decode_generic[Comment](params)!
|
|
||||||
o = f.comments.set(o)!
|
|
||||||
return new_response_int(rpcid, int(o.id))
|
|
||||||
}
|
|
||||||
'delete' {
|
|
||||||
id := db.decode_u32(params)!
|
|
||||||
f.comments.delete(id)!
|
|
||||||
return new_response_ok(rpcid)
|
|
||||||
}
|
|
||||||
'exist' {
|
|
||||||
id := db.decode_u32(params)!
|
|
||||||
if f.comments.exist(id)! {
|
|
||||||
return new_response_true(rpcid)
|
|
||||||
} else {
|
|
||||||
return new_response_false(rpcid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'list' {
|
|
||||||
req := jsonrpc.new_request(method, '')
|
|
||||||
res := f.comments.list()!
|
|
||||||
return new_response(req.id, json.encode(res))
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new_error(rpcid,
|
|
||||||
code: 32601
|
|
||||||
message: 'Method ${method} not found on comment'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,21 +3,24 @@ module heromodels
|
|||||||
import freeflowuniverse.herolib.data.encoder
|
import freeflowuniverse.herolib.data.encoder
|
||||||
import freeflowuniverse.herolib.data.ourtime
|
import freeflowuniverse.herolib.data.ourtime
|
||||||
import freeflowuniverse.herolib.hero.db
|
import freeflowuniverse.herolib.hero.db
|
||||||
|
import freeflowuniverse.herolib.schemas.jsonrpc { Response, new_error, new_response, new_response_false, new_response_ok, new_response_true, new_response_int }
|
||||||
|
import freeflowuniverse.herolib.hero.user { UserRef }
|
||||||
|
import json
|
||||||
|
|
||||||
// Contact represents a person in the system
|
// Contact represents a person in the system
|
||||||
@[heap]
|
@[heap]
|
||||||
pub struct Contact {
|
pub struct Contact {
|
||||||
db.Base
|
db.Base
|
||||||
pub mut:
|
pub mut:
|
||||||
email string
|
emails []string
|
||||||
user_id u32 // id as is set in ledger, if 0 then we don't know
|
user_id u32 // id as is set in ledger, if 0 then we don't know
|
||||||
phone string
|
phones []string
|
||||||
address string
|
addresses []string
|
||||||
avatar_url string
|
avatar_url string
|
||||||
bio string
|
bio string
|
||||||
timezone string
|
timezone string
|
||||||
status ContactStatus
|
status ContactStatus
|
||||||
profile_ids []string
|
profile_ids []u32
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum ContactStatus {
|
pub enum ContactStatus {
|
||||||
@@ -78,10 +81,10 @@ pub fn (self Contact) example(methodname string) (string, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self Contact) dump(mut e encoder.Encoder) ! {
|
pub fn (self Contact) dump(mut e encoder.Encoder) ! {
|
||||||
e.add_string(self.email)
|
e.add_list_string(self.emails)
|
||||||
e.add_string(self.public_key)
|
e.add_u32(self.user_id)
|
||||||
e.add_string(self.phone)
|
e.add_list_string(self.phones)
|
||||||
e.add_string(self.address)
|
e.add_list_string(self.addresses)
|
||||||
e.add_string(self.avatar_url)
|
e.add_string(self.avatar_url)
|
||||||
e.add_string(self.bio)
|
e.add_string(self.bio)
|
||||||
e.add_string(self.timezone)
|
e.add_string(self.timezone)
|
||||||
@@ -89,10 +92,10 @@ pub fn (self Contact) dump(mut e encoder.Encoder) ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DBContact) load(mut o Contact, mut e encoder.Decoder) ! {
|
fn (mut self DBContact) load(mut o Contact, mut e encoder.Decoder) ! {
|
||||||
o.email = e.get_string()!
|
o.emails = e.get_list_string()!
|
||||||
o.public_key = e.get_string()!
|
o.user_id = e.get_u32()!
|
||||||
o.phone = e.get_string()!
|
o.phones = e.get_list_string()!
|
||||||
o.address = e.get_string()!
|
o.addresses = e.get_list_string()!
|
||||||
o.avatar_url = e.get_string()!
|
o.avatar_url = e.get_string()!
|
||||||
o.bio = e.get_string()!
|
o.bio = e.get_string()!
|
||||||
o.timezone = e.get_string()!
|
o.timezone = e.get_string()!
|
||||||
@@ -104,10 +107,9 @@ pub struct ContactArg {
|
|||||||
pub mut:
|
pub mut:
|
||||||
name string @[required]
|
name string @[required]
|
||||||
description string
|
description string
|
||||||
email string
|
emails []string
|
||||||
public_key string // for encryption/signing
|
phones []string
|
||||||
phone string
|
addresses []string
|
||||||
address string
|
|
||||||
avatar_url string
|
avatar_url string
|
||||||
bio string
|
bio string
|
||||||
timezone string
|
timezone string
|
||||||
@@ -132,10 +134,9 @@ pub mut:
|
|||||||
// get new contact, not from the DB
|
// get new contact, not from the DB
|
||||||
pub fn (mut self DBContact) new(args ContactArg) !Contact {
|
pub fn (mut self DBContact) new(args ContactArg) !Contact {
|
||||||
mut o := Contact{
|
mut o := Contact{
|
||||||
email: args.email
|
emails: args.emails
|
||||||
public_key: args.public_key
|
phones: args.phones
|
||||||
phone: args.phone
|
addresses: args.addresses
|
||||||
address: args.address
|
|
||||||
avatar_url: args.avatar_url
|
avatar_url: args.avatar_url
|
||||||
bio: args.bio
|
bio: args.bio
|
||||||
timezone: args.timezone
|
timezone: args.timezone
|
||||||
@@ -203,3 +204,43 @@ pub fn (mut self DBContact) list(args ContactListArg) ![]Contact {
|
|||||||
|
|
||||||
return filtered_contacts
|
return filtered_contacts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn contact_handle(mut f ModelsFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response {
|
||||||
|
match method {
|
||||||
|
'get' {
|
||||||
|
id := db.decode_u32(params)!
|
||||||
|
res := f.contact.get(id)!
|
||||||
|
return new_response(rpcid, json.encode(res))
|
||||||
|
}
|
||||||
|
'set' {
|
||||||
|
mut o := db.decode_generic[Contact](params)!
|
||||||
|
o = f.contact.set(o)!
|
||||||
|
return new_response_int(rpcid, int(o.id))
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
id := db.decode_u32(params)!
|
||||||
|
f.contact.delete(id)!
|
||||||
|
return new_response_ok(rpcid)
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
id := db.decode_u32(params)!
|
||||||
|
if f.contact.exist(id)! {
|
||||||
|
return new_response_true(rpcid)
|
||||||
|
} else {
|
||||||
|
return new_response_false(rpcid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
req := jsonrpc.new_request(method, '')
|
||||||
|
res := f.contact.list(ContactListArg{})!
|
||||||
|
return new_response(req.id, json.encode(res))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new_error(rpcid,
|
||||||
|
code: 32601
|
||||||
|
message: 'Method ${method} not found on contact'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,8 @@ pub mut:
|
|||||||
project_issue DBProjectIssue
|
project_issue DBProjectIssue
|
||||||
chat_group DBChatGroup
|
chat_group DBChatGroup
|
||||||
chat_message DBChatMessage
|
chat_message DBChatMessage
|
||||||
|
contact DBContact
|
||||||
|
profile DBProfile
|
||||||
rpc_handler &Handler
|
rpc_handler &Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +73,12 @@ pub fn new(args NewArgs) !&ModelsFactory {
|
|||||||
chat_message: DBChatMessage{
|
chat_message: DBChatMessage{
|
||||||
db: &mydb
|
db: &mydb
|
||||||
}
|
}
|
||||||
|
contact: DBContact{
|
||||||
|
db: &mydb
|
||||||
|
}
|
||||||
|
profile: DBProfile{
|
||||||
|
db: &mydb
|
||||||
|
}
|
||||||
rpc_handler: &h
|
rpc_handler: &h
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +138,12 @@ pub fn group_api_handler(rpcid int, servercontext map[string]string, actorname s
|
|||||||
'user' {
|
'user' {
|
||||||
return user_handle(mut f, rpcid, servercontext, userref, methodname, params)!
|
return user_handle(mut f, rpcid, servercontext, userref, methodname, params)!
|
||||||
}
|
}
|
||||||
|
'contact' {
|
||||||
|
return contact_handle(mut f, rpcid, servercontext, userref, methodname, params)!
|
||||||
|
}
|
||||||
|
'profile' {
|
||||||
|
return profile_handle(mut f, rpcid, servercontext, userref, methodname, params)!
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return jsonrpc.new_error(rpcid,
|
return jsonrpc.new_error(rpcid,
|
||||||
code: 32111
|
code: 32111
|
||||||
|
|||||||
@@ -21,17 +21,6 @@ pub mut:
|
|||||||
attendees_optional []u32 //if we want to specify upfront
|
attendees_optional []u32 //if we want to specify upfront
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RecurrenceRule {
|
|
||||||
pub mut:
|
|
||||||
// cron string // in linux cron format, if cron used then other ones below not used
|
|
||||||
until u64 // End date (Unix timestamp)
|
|
||||||
by_weekday []u8 // Days of week (0=Sunday)
|
|
||||||
by_monthday []u8 // Days of month
|
|
||||||
hour_from u8 // starts at midnight e.g. 10
|
|
||||||
hour_to u8 // e.g. 12 means between 10 and 12 (noon)
|
|
||||||
duration int // in minutes e.g. 30, means half hour
|
|
||||||
priority u8 // to tell user what has our preference, higher nr is better, max 10
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +1,44 @@
|
|||||||
module heromodels
|
module heromodels
|
||||||
|
|
||||||
import time
|
import freeflowuniverse.herolib.data.encoder
|
||||||
|
import freeflowuniverse.herolib.data.ourtime
|
||||||
|
import freeflowuniverse.herolib.hero.db
|
||||||
|
import freeflowuniverse.herolib.schemas.jsonrpc { Response, new_error, new_response, new_response_false, new_response_ok, new_response_true, new_response_int }
|
||||||
|
import freeflowuniverse.herolib.hero.user { UserRef }
|
||||||
|
import json
|
||||||
|
|
||||||
|
@[heap]
|
||||||
pub struct Profile {
|
pub struct Profile {
|
||||||
pub:
|
db.Base
|
||||||
id string
|
pub mut:
|
||||||
user_id string // a user can have more than one profile
|
user_id u32 // a user can have more than one profile
|
||||||
name string
|
summary string
|
||||||
summary string
|
headline string
|
||||||
headline string
|
location string
|
||||||
location string
|
industry string
|
||||||
industry string
|
|
||||||
// urls to profile pictures
|
// urls to profile pictures
|
||||||
picture_url string
|
picture_url string
|
||||||
background_image_url string
|
background_image_url string
|
||||||
// contact info
|
// contact info
|
||||||
email string
|
email string
|
||||||
phone string
|
phone string
|
||||||
website string
|
website string
|
||||||
// experience
|
// experience
|
||||||
experience []Experience
|
experience []Experience
|
||||||
education []Education
|
education []Education
|
||||||
skills []string
|
skills []string
|
||||||
languages []string
|
languages []string
|
||||||
// recommendations
|
|
||||||
recommendations_received []Recommendation
|
|
||||||
recommendations_given []Recommendation
|
|
||||||
// connections
|
|
||||||
connections []string // user_ids
|
|
||||||
// groups the profile is part of
|
|
||||||
group_ids []string
|
|
||||||
// creation and modification times
|
|
||||||
created time.Time
|
|
||||||
modified time.Time
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Experience {
|
pub struct Experience {
|
||||||
pub:
|
pub:
|
||||||
title string
|
title string
|
||||||
company string
|
company string
|
||||||
location string
|
location string
|
||||||
start_date time.Time
|
start_date u64
|
||||||
end_date time.Time
|
end_date u64
|
||||||
current bool
|
current bool
|
||||||
description string
|
description string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Education {
|
pub struct Education {
|
||||||
@@ -51,15 +46,215 @@ pub:
|
|||||||
school string
|
school string
|
||||||
degree string
|
degree string
|
||||||
field_of_study string
|
field_of_study string
|
||||||
start_date time.Time
|
start_date u64
|
||||||
end_date time.Time
|
end_date u64
|
||||||
description string
|
description string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Recommendation {
|
pub struct DBProfile {
|
||||||
pub:
|
pub mut:
|
||||||
recommender_id string
|
db &db.DB @[skip; str: skip]
|
||||||
receiver_id string
|
}
|
||||||
text string
|
|
||||||
created time.Time
|
pub fn (self Profile) type_name() string {
|
||||||
|
return 'profile'
|
||||||
|
}
|
||||||
|
|
||||||
|
// return example rpc call and result for each methodname
|
||||||
|
pub fn (self Profile) description(methodname string) string {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return 'Create or update a profile. Returns the ID of the profile.'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return 'Retrieve a profile by ID. Returns the profile object.'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return 'Delete a profile by ID. Returns true if successful.'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return 'Check if a profile exists by ID. Returns true or false.'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return 'List all profiles. Returns an array of profile 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 Profile) example(methodname string) (string, string) {
|
||||||
|
match methodname {
|
||||||
|
'set' {
|
||||||
|
return '{"profile": {"name": "John Doe", "summary": "Software Engineer", "headline": "Building the future", "location": "San Francisco", "industry": "IT", "picture_url": "http://example.com/pic.jpg", "background_image_url": "http://example.com/bg.jpg", "email": "john.doe@example.com", "phone": "123456789", "website": "example.com", "experience": [{"title": "Software Engineer", "company": "Example Inc.", "location": "SF", "start_date": 1609459200, "end_date": 0, "current": true, "description": "Worked on stuff."}], "education": [{"school": "Example University", "degree": "BS", "field_of_study": "CS", "start_date": 1483228800, "end_date": 1609459200, "description": "Learned stuff."}], "skills": ["Vlang", "Go"], "languages": ["English"]}}', '1'
|
||||||
|
}
|
||||||
|
'get' {
|
||||||
|
return '{"id": 1}', '{"name": "John Doe", "summary": "Software Engineer", "headline": "Building the future", "location": "San Francisco", "industry": "IT", "picture_url": "http://example.com/pic.jpg", "background_image_url": "http://example.com/bg.jpg", "email": "john.doe@example.com", "phone": "123456789", "website": "example.com", "experience": [{"title": "Software Engineer", "company": "Example Inc.", "location": "SF", "start_date": 1609459200, "end_date": 0, "current": true, "description": "Worked on stuff."}], "education": [{"school": "Example University", "degree": "BS", "field_of_study": "CS", "start_date": 1483228800, "end_date": 1609459200, "description": "Learned stuff."}], "skills": ["Vlang", "Go"], "languages": ["English"]}'
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
return '{"id": 1}', 'true'
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
return '{}', '[{"name": "John Doe", "summary": "Software Engineer", "headline": "Building the future", "location": "San Francisco", "industry": "IT", "picture_url": "http://example.com/pic.jpg", "background_image_url": "http://example.com/bg.jpg", "email": "john.doe@example.com", "phone": "123456789", "website": "example.com", "experience": [{"title": "Software Engineer", "company": "Example Inc.", "location": "SF", "start_date": 1609459200, "end_date": 0, "current": true, "description": "Worked on stuff."}], "education": [{"school": "Example University", "degree": "BS", "field_of_study": "CS", "start_date": 1483228800, "end_date": 1609459200, "description": "Learned stuff."}], "skills": ["Vlang", "Go"], "languages": ["English"]}]'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '{}', '{}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (self Profile) dump(mut e encoder.Encoder) ! {
|
||||||
|
e.add_u32(self.user_id)
|
||||||
|
e.add_string(self.summary)
|
||||||
|
e.add_string(self.headline)
|
||||||
|
e.add_string(self.location)
|
||||||
|
e.add_string(self.industry)
|
||||||
|
e.add_string(self.picture_url)
|
||||||
|
e.add_string(self.background_image_url)
|
||||||
|
e.add_string(self.email)
|
||||||
|
e.add_string(self.phone)
|
||||||
|
e.add_string(self.website)
|
||||||
|
e.add_string(json.encode_pretty(self.experience))
|
||||||
|
e.add_string(json.encode_pretty(self.education))
|
||||||
|
e.add_list_string(self.skills)
|
||||||
|
e.add_list_string(self.languages)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn (mut self DBProfile) load(mut o Profile, mut e encoder.Decoder) ! {
|
||||||
|
o.user_id = e.get_u32()!
|
||||||
|
o.summary = e.get_string()!
|
||||||
|
o.headline = e.get_string()!
|
||||||
|
o.location = e.get_string()!
|
||||||
|
o.industry = e.get_string()!
|
||||||
|
o.picture_url = e.get_string()!
|
||||||
|
o.background_image_url = e.get_string()!
|
||||||
|
o.email = e.get_string()!
|
||||||
|
o.phone = e.get_string()!
|
||||||
|
o.website = e.get_string()!
|
||||||
|
o.experience = json.decode([]Experience, e.get_string()!)!
|
||||||
|
o.education = json.decode([]Education, e.get_string()!)!
|
||||||
|
o.skills = e.get_list_string()!
|
||||||
|
o.languages = e.get_list_string()!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@[params]
|
||||||
|
pub struct ProfileArg {
|
||||||
|
pub mut:
|
||||||
|
name string
|
||||||
|
description string
|
||||||
|
user_id u32 // a user can have more than one profile
|
||||||
|
summary string
|
||||||
|
headline string
|
||||||
|
location string
|
||||||
|
industry string
|
||||||
|
picture_url string
|
||||||
|
background_image_url string
|
||||||
|
email string
|
||||||
|
phone string
|
||||||
|
website string
|
||||||
|
experience []Experience
|
||||||
|
education []Education
|
||||||
|
skills []string
|
||||||
|
languages []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// get new profile, not from the DB
|
||||||
|
pub fn (mut self DBProfile) new(args ProfileArg) !Profile {
|
||||||
|
mut o := Profile{
|
||||||
|
user_id: args.user_id
|
||||||
|
summary: args.summary
|
||||||
|
headline: args.headline
|
||||||
|
location: args.location
|
||||||
|
industry: args.industry
|
||||||
|
picture_url: args.picture_url
|
||||||
|
background_image_url: args.background_image_url
|
||||||
|
email: args.email
|
||||||
|
phone: args.phone
|
||||||
|
website: args.website
|
||||||
|
experience: args.experience
|
||||||
|
education: args.education
|
||||||
|
skills: args.skills
|
||||||
|
languages: args.languages
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set base fields
|
||||||
|
o.name = args.name
|
||||||
|
o.description = args.description
|
||||||
|
o.updated_at = ourtime.now().unix()
|
||||||
|
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (mut self DBProfile) set(o Profile) !Profile {
|
||||||
|
// Use db set function which returns the object with assigned ID
|
||||||
|
return self.db.set[Profile](o)!
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (mut self DBProfile) delete(id u32) ! {
|
||||||
|
self.db.delete[Profile](id)!
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (mut self DBProfile) exist(id u32) !bool {
|
||||||
|
return self.db.exists[Profile](id)!
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (mut self DBProfile) get(id u32) !Profile {
|
||||||
|
mut o, data := self.db.get_data[Profile](id)!
|
||||||
|
mut e_decoder := encoder.decoder_new(data)
|
||||||
|
self.load(mut o, mut e_decoder)!
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (mut self DBProfile) list() ![]Profile {
|
||||||
|
r := self.db.list[Profile]()!.map(self.get(it)!)
|
||||||
|
println(r)
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn profile_handle(mut f ModelsFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response {
|
||||||
|
match method {
|
||||||
|
'get' {
|
||||||
|
id := db.decode_u32(params)!
|
||||||
|
res := f.profile.get(id)!
|
||||||
|
return new_response(rpcid, json.encode_pretty(res))
|
||||||
|
}
|
||||||
|
'set' {
|
||||||
|
mut o := db.decode_generic[Profile](params)!
|
||||||
|
o=f.profile.set(o)!
|
||||||
|
return new_response_int(rpcid,int(o.id))
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
id := db.decode_u32(params)!
|
||||||
|
f.profile.delete(id)!
|
||||||
|
return new_response_ok(rpcid)
|
||||||
|
}
|
||||||
|
'exist' {
|
||||||
|
id := db.decode_u32(params)!
|
||||||
|
if f.profile.exist(id)! {
|
||||||
|
return new_response_true(rpcid)
|
||||||
|
} else {
|
||||||
|
return new_response_false(rpcid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'list' {
|
||||||
|
req := jsonrpc.new_request(method, '') // no params
|
||||||
|
res := f.profile.list()!
|
||||||
|
return new_response(req.id, json.encode_pretty(res))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
println('Method not found on profile: ${method}')
|
||||||
|
$dbg;
|
||||||
|
return new_error(rpcid,
|
||||||
|
code: 32601
|
||||||
|
message: 'Method ${method} not found on profile'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import freeflowuniverse.herolib.schemas.openrpc
|
|
||||||
import os
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels.rpc.rpc_planning
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels.rpc.rpc_registration_desk
|
|
||||||
|
|
||||||
const openrpc_path = os.join_path(os.dir(@FILE), 'openrpc.json')
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ServerArgs {
|
|
||||||
pub mut:
|
|
||||||
socket_path string = '/tmp/heromodels'
|
|
||||||
http_port int // if 0, no http server will be started
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn start(args ServerArgs) ! {
|
|
||||||
mut openrpc_handler := openrpc.new_handler(openrpc_path)!
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('message_get', message_get)
|
|
||||||
openrpc_handler.register_procedure_handle('message_set', message_set)
|
|
||||||
openrpc_handler.register_procedure_handle('message_delete', message_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('message_list', message_list)
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('calendar_get', calendar_get)
|
|
||||||
openrpc_handler.register_procedure_handle('calendar_set', calendar_set)
|
|
||||||
openrpc_handler.register_procedure_handle('calendar_delete', calendar_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('calendar_list', calendar_list)
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('calendar_event_get', calendar_event_get)
|
|
||||||
openrpc_handler.register_procedure_handle('calendar_event_set', calendar_event_set)
|
|
||||||
openrpc_handler.register_procedure_handle('calendar_event_delete', calendar_event_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('calendar_event_list', calendar_event_list)
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('chat_group_get', chat_group_get)
|
|
||||||
openrpc_handler.register_procedure_handle('chat_group_set', chat_group_set)
|
|
||||||
openrpc_handler.register_procedure_handle('chat_group_delete', chat_group_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('chat_group_list', chat_group_list)
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('chat_message_get', chat_message_get)
|
|
||||||
openrpc_handler.register_procedure_handle('chat_message_set', chat_message_set)
|
|
||||||
openrpc_handler.register_procedure_handle('chat_message_delete', chat_message_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('chat_message_list', chat_message_list)
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('group_get', group_get)
|
|
||||||
openrpc_handler.register_procedure_handle('group_set', group_set)
|
|
||||||
openrpc_handler.register_procedure_handle('group_delete', group_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('group_list', group_list)
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('project_issue_get', project_issue_get)
|
|
||||||
openrpc_handler.register_procedure_handle('project_issue_set', project_issue_set)
|
|
||||||
openrpc_handler.register_procedure_handle('project_issue_delete', project_issue_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('project_issue_list', project_issue_list)
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('project_get', project_get)
|
|
||||||
openrpc_handler.register_procedure_handle('project_set', project_set)
|
|
||||||
openrpc_handler.register_procedure_handle('project_delete', project_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('project_list', project_list)
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('user_get', user_get)
|
|
||||||
openrpc_handler.register_procedure_handle('user_set', user_set)
|
|
||||||
openrpc_handler.register_procedure_handle('user_delete', user_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('user_list', user_list)
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('planning_get', rpc_planning.planning_get)
|
|
||||||
openrpc_handler.register_procedure_handle('planning_set', rpc_planning.planning_set)
|
|
||||||
openrpc_handler.register_procedure_handle('planning_delete', rpc_planning.planning_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('planning_exist', rpc_planning.planning_exist)
|
|
||||||
openrpc_handler.register_procedure_handle('planning_list', rpc_planning.planning_list)
|
|
||||||
|
|
||||||
openrpc_handler.register_procedure_handle('registration_desk_get', rpc_registration_desk.registration_desk_get)
|
|
||||||
openrpc_handler.register_procedure_handle('registration_desk_set', rpc_registration_desk.registration_desk_set)
|
|
||||||
openrpc_handler.register_procedure_handle('registration_desk_delete', rpc_registration_desk.registration_desk_delete)
|
|
||||||
openrpc_handler.register_procedure_handle('registration_desk_exist', rpc_registration_desk.registration_desk_exist)
|
|
||||||
openrpc_handler.register_procedure_handle('registration_desk_list', rpc_registration_desk.registration_desk_list)
|
|
||||||
|
|
||||||
if args.http_port != 0 {
|
|
||||||
openrpc.start_http_server(openrpc_handler, port: args.http_port)!
|
|
||||||
} else {
|
|
||||||
openrpc.start_unix_server(openrpc_handler, socket_path: args.socket_path)!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
|
|
||||||
// Calendar-specific argument structures
|
|
||||||
@[params]
|
|
||||||
pub struct CalendarGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct CalendarSetArgs {
|
|
||||||
pub mut:
|
|
||||||
name string @[required]
|
|
||||||
description string
|
|
||||||
color string
|
|
||||||
timezone string
|
|
||||||
is_public bool
|
|
||||||
events []u32
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct CalendarDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn calendar_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[CalendarGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
calendar := mydb.calendar.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(calendar))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn calendar_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[CalendarSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut calendar_obj := mydb.calendar.new(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
color: payload.color
|
|
||||||
timezone: payload.timezone
|
|
||||||
is_public: payload.is_public
|
|
||||||
events: payload.events
|
|
||||||
)!
|
|
||||||
|
|
||||||
calendar_obj=mydb.calendar.set( calendar_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, calendar_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn calendar_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[CalendarDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.calendar.delete(payload.id)!
|
|
||||||
|
|
||||||
// returns
|
|
||||||
return new_response_true(request.id) // return true as jsonrpc (bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn calendar_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[CalendarListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
calendars := mydb.calendar.list(
|
|
||||||
is_public: payload.is_public
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(calendars))
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct CalendarListArgs {
|
|
||||||
pub mut:
|
|
||||||
is_public bool
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
import freeflowuniverse.herolib.hero.db
|
|
||||||
// CalendarEvent-specific argument structures
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct CalendarEventGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct CalendarEventSetArgs {
|
|
||||||
pub mut:
|
|
||||||
name string
|
|
||||||
description string
|
|
||||||
title string
|
|
||||||
start_time string // use ourtime module to go from string to epoch
|
|
||||||
end_time string // use ourtime module to go from string to epoch
|
|
||||||
registration_desks []u32 //link to registration mechanism, is where we track invitees, are not attendee unless accepted
|
|
||||||
attendees []heromodels.AttendeeArg
|
|
||||||
docs []heromodels.EventDocArg // IDs of linked files or dirs
|
|
||||||
calendar_id u32 // Associated calendar
|
|
||||||
status heromodels.EventStatus
|
|
||||||
is_all_day bool
|
|
||||||
reminder_mins []int // Minutes before event for reminders
|
|
||||||
color string // Hex color code
|
|
||||||
timezone string
|
|
||||||
priority heromodels.EventPriority
|
|
||||||
public bool
|
|
||||||
locations []heromodels.EventLocationArg
|
|
||||||
is_template bool //not to be shown as real event, serves as placeholder e.g. for planning
|
|
||||||
securitypolicy u32
|
|
||||||
tags []string
|
|
||||||
messages []db.MessageArg
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct AttendeeArg {
|
|
||||||
pub mut:
|
|
||||||
user_id u32
|
|
||||||
status_latest heromodels.AttendanceStatus
|
|
||||||
attendance_required bool
|
|
||||||
admin bool
|
|
||||||
organizer bool
|
|
||||||
log []heromodels.AttendeeLog
|
|
||||||
location string
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct EventDocArg {
|
|
||||||
pub mut:
|
|
||||||
fs_item u32
|
|
||||||
cat string
|
|
||||||
public bool
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct EventLocationArg {
|
|
||||||
pub mut:
|
|
||||||
name string
|
|
||||||
description string
|
|
||||||
cat heromodels.EventLocationCat
|
|
||||||
docs []heromodels.EventDoc // link to docs
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct CalendarEventDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn calendar_event_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[CalendarEventGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
calendar_event := mydb.calendar_event.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(calendar_event))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn calendar_event_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[CalendarEventSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut calendar_event_obj := mydb.calendar_event.new(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
title: payload.title
|
|
||||||
start_time: payload.start_time
|
|
||||||
end_time: payload.end_time
|
|
||||||
registration_desks: payload.registration_desks
|
|
||||||
attendees: payload.attendees
|
|
||||||
docs: payload.docs
|
|
||||||
calendar_id: payload.calendar_id
|
|
||||||
status: payload.status
|
|
||||||
is_all_day: payload.is_all_day
|
|
||||||
reminder_mins: payload.reminder_mins
|
|
||||||
color: payload.color
|
|
||||||
timezone: payload.timezone
|
|
||||||
priority: payload.priority
|
|
||||||
public: payload.public
|
|
||||||
locations: payload.locations
|
|
||||||
is_template: payload.is_template
|
|
||||||
securitypolicy: payload.securitypolicy
|
|
||||||
tags: payload.tags
|
|
||||||
messages: payload.messages
|
|
||||||
)!
|
|
||||||
|
|
||||||
calendar_event_obj = mydb.calendar_event.set(calendar_event_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, calendar_event_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn calendar_event_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[CalendarEventDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.calendar_event.delete(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id) // return true as jsonrpc (bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn calendar_event_exist(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[CalendarEventGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
exists := mydb.calendar_event.exist(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id) // return true as jsonrpc (bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct CalendarEventListArgs {
|
|
||||||
pub mut:
|
|
||||||
calendar_id u32
|
|
||||||
status heromodels.EventStatus
|
|
||||||
public bool
|
|
||||||
limit int = 100 // Default limit is 100
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn calendar_event_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[CalendarEventListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
calendar_events := mydb.calendar_event.list(payload)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(calendar_events))
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
import freeflowuniverse.herolib.hero.db
|
|
||||||
// ChatGroup-specific argument structures
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ChatGroupGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ChatGroupSetArgs {
|
|
||||||
pub mut:
|
|
||||||
name string
|
|
||||||
description string
|
|
||||||
chat_type heromodels.ChatType
|
|
||||||
last_activity i64
|
|
||||||
is_archived bool
|
|
||||||
securitypolicy u32
|
|
||||||
tags []string
|
|
||||||
messages []db.MessageArg
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ChatGroupDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chat_group_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ChatGroupGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
chat_group := mydb.chat_group.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(chat_group))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chat_group_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ChatGroupSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut chat_group_obj := mydb.chat_group.new(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
chat_type: payload.chat_type
|
|
||||||
last_activity: payload.last_activity
|
|
||||||
is_archived: payload.is_archived
|
|
||||||
securitypolicy: payload.securitypolicy
|
|
||||||
tags: payload.tags
|
|
||||||
messages: payload.messages
|
|
||||||
)!
|
|
||||||
|
|
||||||
chat_group_obj=mydb.chat_group.set( chat_group_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, chat_group_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chat_group_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ChatGroupDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.chat_group.delete(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id) // return true as jsonrpc (bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chat_group_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ChatGroupListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
chat_groups := mydb.chat_group.list(
|
|
||||||
chat_type: payload.chat_type
|
|
||||||
is_archived: payload.is_archived
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(chat_groups))
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ChatGroupListArgs {
|
|
||||||
pub mut:
|
|
||||||
chat_type heromodels.ChatType
|
|
||||||
is_archived bool
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
import freeflowuniverse.herolib.hero.db
|
|
||||||
// ChatMessage-specific argument structures
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ChatMessageGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ChatMessageSetArgs {
|
|
||||||
pub mut:
|
|
||||||
name string
|
|
||||||
description string
|
|
||||||
content string
|
|
||||||
chat_group_id u32
|
|
||||||
sender_id u32
|
|
||||||
parent_messages []heromodels.MessageLink
|
|
||||||
fs_files []u32
|
|
||||||
message_type heromodels.MessageType
|
|
||||||
status heromodels.MessageStatus
|
|
||||||
reactions []heromodels.MessageReaction
|
|
||||||
mentions []u32
|
|
||||||
securitypolicy u32
|
|
||||||
tags []string
|
|
||||||
messages []db.MessageArg
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ChatMessageDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chat_message_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ChatMessageGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
chat_message := mydb.chat_message.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(chat_message))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chat_message_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ChatMessageSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut chat_message_obj := mydb.chat_message.new(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
content: payload.content
|
|
||||||
chat_group_id: payload.chat_group_id
|
|
||||||
sender_id: payload.sender_id
|
|
||||||
parent_messages: payload.parent_messages
|
|
||||||
fs_files: payload.fs_files
|
|
||||||
message_type: payload.message_type
|
|
||||||
status: payload.status
|
|
||||||
reactions: payload.reactions
|
|
||||||
mentions: payload.mentions
|
|
||||||
securitypolicy: payload.securitypolicy
|
|
||||||
tags: payload.tags
|
|
||||||
messages: payload.messages
|
|
||||||
)!
|
|
||||||
|
|
||||||
chat_message_obj=mydb.chat_message.set( chat_message_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, chat_message_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chat_message_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ChatMessageDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.chat_message.delete(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id) // return true as jsonrpc (bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chat_message_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ChatMessageListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
chat_messages := mydb.chat_message.list(
|
|
||||||
parent: payload.parent
|
|
||||||
author: payload.author
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(chat_messages))
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ChatMessageListArgs {
|
|
||||||
pub mut:
|
|
||||||
parent u32
|
|
||||||
author u32
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
|
|
||||||
// Group-specific argument structures
|
|
||||||
@[params]
|
|
||||||
pub struct GroupGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct GroupSetArgs {
|
|
||||||
pub mut:
|
|
||||||
name string
|
|
||||||
description string
|
|
||||||
members []heromodels.GroupMember
|
|
||||||
subgroups []u32
|
|
||||||
parent_group u32
|
|
||||||
is_public bool
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct GroupDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn group_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[GroupGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
group := mydb.group.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(group))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn group_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[GroupSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut group_obj := mydb.group.new(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
members: payload.members
|
|
||||||
subgroups: payload.subgroups
|
|
||||||
parent_group: payload.parent_group
|
|
||||||
is_public: payload.is_public
|
|
||||||
)!
|
|
||||||
|
|
||||||
group_obj=mydb.group.set( group_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, group_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn group_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[GroupDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.group.delete(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id) // return true as jsonrpc (bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn group_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[GroupListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
groups := mydb.group.list(
|
|
||||||
is_public: payload.is_public
|
|
||||||
parent_group: payload.parent_group
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(groups))
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct GroupListArgs {
|
|
||||||
pub mut:
|
|
||||||
is_public bool
|
|
||||||
parent_group u32
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ChatGroupListArgs {
|
|
||||||
pub mut:
|
|
||||||
chat_type heromodels.ChatType
|
|
||||||
is_archived bool
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chat_group_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ChatGroupListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
chat_groups := mydb.chat_group.list(
|
|
||||||
chat_type: payload.chat_type
|
|
||||||
is_archived: payload.is_archived
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(chat_groups))
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
import freeflowuniverse.herolib.hero.db
|
|
||||||
|
|
||||||
// Project-specific argument structures
|
|
||||||
@[params]
|
|
||||||
pub struct ProjectGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ProjectSetArgs {
|
|
||||||
pub mut:
|
|
||||||
name string
|
|
||||||
description string
|
|
||||||
swimlanes []heromodels.Swimlane
|
|
||||||
milestones []heromodels.Milestone
|
|
||||||
issues []string
|
|
||||||
fs_files []u32
|
|
||||||
status heromodels.ProjectStatus
|
|
||||||
start_date string // Use ourtime module to convert to epoch
|
|
||||||
end_date string // Use ourtime module to convert to epoch
|
|
||||||
securitypolicy u32
|
|
||||||
tags []string
|
|
||||||
messages []db.MessageArg
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ProjectDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn project_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ProjectGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
project := mydb.project.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(project))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn project_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ProjectSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut project_obj := mydb.project.new(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
swimlanes: payload.swimlanes
|
|
||||||
milestones: payload.milestones
|
|
||||||
issues: payload.issues
|
|
||||||
fs_files: payload.fs_files
|
|
||||||
status: payload.status
|
|
||||||
start_date: payload.start_date
|
|
||||||
end_date: payload.end_date
|
|
||||||
securitypolicy: payload.securitypolicy
|
|
||||||
tags: payload.tags
|
|
||||||
messages: payload.messages
|
|
||||||
)!
|
|
||||||
|
|
||||||
project_obj = mydb.project.set(project_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, project_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn project_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ProjectDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.project.delete(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id) // return true as jsonrpc (bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn project_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ProjectListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
projects := mydb.project.list(
|
|
||||||
status: payload.status
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(projects))
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ProjectListArgs {
|
|
||||||
pub mut:
|
|
||||||
status heromodels.ProjectStatus
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
import freeflowuniverse.herolib.hero.db
|
|
||||||
// ProjectIssue-specific argument structures
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ProjectIssueGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ProjectIssueSetArgs {
|
|
||||||
pub mut:
|
|
||||||
name string
|
|
||||||
description string
|
|
||||||
title string
|
|
||||||
project_id u32
|
|
||||||
issue_type heromodels.IssueType
|
|
||||||
priority heromodels.IssuePriority
|
|
||||||
status heromodels.IssueStatus
|
|
||||||
swimlane string
|
|
||||||
assignees []u32
|
|
||||||
reporter u32
|
|
||||||
milestone string
|
|
||||||
deadline string // Use ourtime module to convert to epoch
|
|
||||||
estimate int
|
|
||||||
fs_files []u32
|
|
||||||
parent_id u32
|
|
||||||
children []u32
|
|
||||||
securitypolicy u32
|
|
||||||
tags []string
|
|
||||||
messages []db.MessageArg
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ProjectIssueDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn project_issue_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ProjectIssueGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
project_issue := mydb.project_issue.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(project_issue))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn project_issue_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ProjectIssueSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut project_issue_obj := mydb.project_issue.new(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
title: payload.title
|
|
||||||
project_id: payload.project_id
|
|
||||||
issue_type: payload.issue_type
|
|
||||||
priority: payload.priority
|
|
||||||
status: payload.status
|
|
||||||
swimlane: payload.swimlane
|
|
||||||
assignees: payload.assignees
|
|
||||||
reporter: payload.reporter
|
|
||||||
milestone: payload.milestone
|
|
||||||
deadline: payload.deadline
|
|
||||||
estimate: payload.estimate
|
|
||||||
fs_files: payload.fs_files
|
|
||||||
parent_id: payload.parent_id
|
|
||||||
children: payload.children
|
|
||||||
securitypolicy: payload.securitypolicy
|
|
||||||
tags: payload.tags
|
|
||||||
messages: payload.messages
|
|
||||||
)!
|
|
||||||
|
|
||||||
project_issue_obj=mydb.project_issue.set( project_issue_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, project_issue_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn project_issue_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ProjectIssueDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.project_issue.delete(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id) // return true as jsonrpc (bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn project_issue_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[ProjectIssueListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
project_issues := mydb.project_issue.list(
|
|
||||||
project_id: payload.project_id
|
|
||||||
issue_type: payload.issue_type
|
|
||||||
status: payload.status
|
|
||||||
swimlane: payload.swimlane
|
|
||||||
milestone: payload.milestone
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(project_issues))
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ProjectIssueListArgs {
|
|
||||||
pub mut:
|
|
||||||
project_id u32
|
|
||||||
issue_type heromodels.IssueType
|
|
||||||
status heromodels.IssueStatus
|
|
||||||
swimlane string
|
|
||||||
milestone string
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
|
|
||||||
// User-specific argument structures
|
|
||||||
@[params]
|
|
||||||
pub struct UserGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct UserSetArgs {
|
|
||||||
pub mut:
|
|
||||||
name string @[required]
|
|
||||||
description string
|
|
||||||
email string
|
|
||||||
public_key string // for encryption/signing
|
|
||||||
phone string
|
|
||||||
address string
|
|
||||||
avatar_url string
|
|
||||||
bio string
|
|
||||||
timezone string
|
|
||||||
status heromodels.UserStatus
|
|
||||||
securitypolicy u32
|
|
||||||
tags u32
|
|
||||||
messages []u32
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct UserDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn user_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[UserGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
user := mydb.user.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(user))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn user_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[UserSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut user_obj := mydb.user.new(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
email: payload.email
|
|
||||||
public_key: payload.public_key
|
|
||||||
phone: payload.phone
|
|
||||||
address: payload.address
|
|
||||||
avatar_url: payload.avatar_url
|
|
||||||
bio: payload.bio
|
|
||||||
timezone: payload.timezone
|
|
||||||
status: payload.status
|
|
||||||
securitypolicy: payload.securitypolicy
|
|
||||||
tags: payload.tags
|
|
||||||
messages: payload.messages
|
|
||||||
)!
|
|
||||||
|
|
||||||
user_obj=mydb.user.set( user_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, user_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn user_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[UserDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.user.delete(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id) // return true as jsonrpc (bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn user_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[UserListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
users := mydb.user.list(
|
|
||||||
status: payload.status
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(users))
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct UserListArgs {
|
|
||||||
pub mut:
|
|
||||||
status heromodels.UserStatus
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
|
|
||||||
// Message-specific argument structures
|
|
||||||
@[params]
|
|
||||||
pub struct MessageGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct MessageSetArgs {
|
|
||||||
pub mut:
|
|
||||||
message string @[required]
|
|
||||||
parent u32
|
|
||||||
author u32
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct MessageDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn message_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[MessageGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
message := mydb.messages.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(message))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn message_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[MessageSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut message_obj := mydb.messages.new(
|
|
||||||
message: payload.message
|
|
||||||
parent: payload.parent
|
|
||||||
author: payload.author
|
|
||||||
)!
|
|
||||||
|
|
||||||
message_obj=mydb.messages.set( message_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, message_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn message_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[MessageDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.messages.delete(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id) // return true as jsonrpc (bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn message_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[MessageListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
messages := mydb.messages.list(
|
|
||||||
parent: payload.parent
|
|
||||||
author: payload.author
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(messages))
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct MessageListArgs {
|
|
||||||
pub mut:
|
|
||||||
parent u32
|
|
||||||
author u32
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
|
|
||||||
// Planning-specific argument structures
|
|
||||||
@[params]
|
|
||||||
pub struct PlanningGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct PlanningSetArgs {
|
|
||||||
pub mut:
|
|
||||||
name string
|
|
||||||
description string
|
|
||||||
color string
|
|
||||||
timezone string
|
|
||||||
is_public bool
|
|
||||||
calendar_template_id u32
|
|
||||||
registration_desk_id u32
|
|
||||||
autoschedule_rules []heromodels.RecurrenceRule
|
|
||||||
invite_rules []heromodels.RecurrenceRule
|
|
||||||
attendees_required []u32
|
|
||||||
attendees_optional []u32
|
|
||||||
securitypolicy u32
|
|
||||||
tags []string
|
|
||||||
messages []heromodels.db.MessageArg
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct PlanningDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct PlanningListArgs {
|
|
||||||
pub mut:
|
|
||||||
is_public bool
|
|
||||||
calendar_template_id u32
|
|
||||||
registration_desk_id u32
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn planning_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[PlanningGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
planning := mydb.plannings.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(planning))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn planning_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[PlanningSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut planning_obj := mydb.plannings.new(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
color: payload.color
|
|
||||||
timezone: payload.timezone
|
|
||||||
is_public: payload.is_public
|
|
||||||
calendar_template_id: payload.calendar_template_id
|
|
||||||
registration_desk_id: payload.registration_desk_id
|
|
||||||
autoschedule_rules: payload.autoschedule_rules
|
|
||||||
invite_rules: payload.invite_rules
|
|
||||||
attendees_required: payload.attendees_required
|
|
||||||
attendees_optional: payload.attendees_optional
|
|
||||||
securitypolicy: payload.securitypolicy
|
|
||||||
tags: payload.tags
|
|
||||||
messages: payload.messages
|
|
||||||
)!
|
|
||||||
|
|
||||||
planning_obj = mydb.plannings.set(planning_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, planning_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn planning_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[PlanningDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.plannings.delete(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn planning_exist(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[PlanningGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
exists := mydb.plannings.exist(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(exists))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn planning_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[PlanningListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
plannings := mydb.plannings.list(
|
|
||||||
is_public: payload.is_public
|
|
||||||
calendar_template_id: payload.calendar_template_id
|
|
||||||
registration_desk_id: payload.registration_desk_id
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(plannings))
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
module rpc
|
|
||||||
|
|
||||||
import json
|
|
||||||
import freeflowuniverse.herolib.schemas.jsonrpc { Request, Response, new_response_true, new_response_u32 }
|
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
|
||||||
|
|
||||||
// RegistrationDesk-specific argument structures
|
|
||||||
@[params]
|
|
||||||
pub struct RegistrationDeskGetArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct RegistrationDeskSetArgs {
|
|
||||||
pub mut:
|
|
||||||
name string
|
|
||||||
description string
|
|
||||||
fs_items []u32
|
|
||||||
white_list []u32
|
|
||||||
white_list_accepted []u32
|
|
||||||
black_list []u32
|
|
||||||
start_time string
|
|
||||||
end_time string
|
|
||||||
acceptance_required bool
|
|
||||||
securitypolicy u32
|
|
||||||
tags []string
|
|
||||||
messages []heromodels.db.MessageArg
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct RegistrationDeskDeleteArgs {
|
|
||||||
pub mut:
|
|
||||||
id u32 @[required]
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct RegistrationDeskListArgs {
|
|
||||||
pub mut:
|
|
||||||
name string
|
|
||||||
description string
|
|
||||||
limit int = 100
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn registration_desk_get(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[RegistrationDeskGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
registration_desk := mydb.registration_desks.get(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(registration_desk))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn registration_desk_set(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[RegistrationDeskSetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mut registration_desk_obj := mydb.registration_desks.new(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
fs_items: payload.fs_items
|
|
||||||
white_list: payload.white_list
|
|
||||||
white_list_accepted: payload.white_list_accepted
|
|
||||||
black_list: payload.black_list
|
|
||||||
start_time: payload.start_time
|
|
||||||
end_time: payload.end_time
|
|
||||||
acceptance_required: payload.acceptance_required
|
|
||||||
securitypolicy: payload.securitypolicy
|
|
||||||
tags: payload.tags
|
|
||||||
messages: payload.messages
|
|
||||||
)!
|
|
||||||
|
|
||||||
registration_desk_obj = mydb.registration_desks.set(registration_desk_obj)!
|
|
||||||
|
|
||||||
return new_response_u32(request.id, registration_desk_obj.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn registration_desk_delete(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[RegistrationDeskDeleteArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
mydb.registration_desks.delete(payload.id)!
|
|
||||||
|
|
||||||
return new_response_true(request.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn registration_desk_exist(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[RegistrationDeskGetArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
exists := mydb.registration_desks.exist(payload.id)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(exists))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn registration_desk_list(request Request) !Response {
|
|
||||||
payload := jsonrpc.decode_payload[RegistrationDeskListArgs](request.params) or {
|
|
||||||
return jsonrpc.invalid_params
|
|
||||||
}
|
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
|
||||||
registration_desks := mydb.registration_desks.list(
|
|
||||||
name: payload.name
|
|
||||||
description: payload.description
|
|
||||||
limit: payload.limit
|
|
||||||
)!
|
|
||||||
|
|
||||||
return jsonrpc.new_response(request.id, json.encode(registration_desks))
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user