WIP: data(base)type
This commit is contained in:
parent
05b0d38490
commit
8dcdfe405e
|
@ -4,6 +4,7 @@ PRAGMA foreign_keys = on;
|
|||
-- TODO: avatar, nick, etc.
|
||||
create table user(
|
||||
jid jid primary key,
|
||||
-- can receive presence status from non-contacts
|
||||
cached_status text,
|
||||
);
|
||||
|
||||
|
@ -36,9 +37,11 @@ create table groups_roster(
|
|||
);
|
||||
|
||||
-- chat includes reference to user jid chat is with
|
||||
-- specifically for dms, groups should be different
|
||||
-- can send chat message to user (creating a new chat if not already exists)
|
||||
create table chats (
|
||||
id uuid primary key,
|
||||
contact_id jid not null unique,
|
||||
user_id jid not null unique,
|
||||
);
|
||||
|
||||
-- messages include reference to chat they are in, and who sent them.
|
||||
|
@ -46,6 +49,7 @@ create table messages (
|
|||
id uuid primary key,
|
||||
body text,
|
||||
chat_id uuid not null,
|
||||
-- TODO: from can be either a jid, a moved jid (for when a contact moves, save original sender jid/user but link to new user), or imported (from another service (save details), linked to new user)
|
||||
from jid not null,
|
||||
-- TODO: read bool not null,
|
||||
foreign key(chat_id) references chats(id),
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::roster::Contact;
|
||||
|
||||
pub enum Chat {
|
||||
Direct(DM),
|
||||
Channel(Channel),
|
||||
}
|
||||
use crate::{roster::Contact, user::User};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Message {
|
||||
id: Uuid,
|
||||
// contains full contact information
|
||||
from: Contact,
|
||||
// contains full user information
|
||||
from: User,
|
||||
// TODO: rich text, other contents, threads
|
||||
body: Body,
|
||||
}
|
||||
|
@ -21,10 +16,15 @@ pub struct Body {
|
|||
body: String,
|
||||
}
|
||||
|
||||
pub struct DM {
|
||||
contact: Contact,
|
||||
pub struct Chat {
|
||||
id: Uuid,
|
||||
user: User,
|
||||
message_history: Vec<Message>,
|
||||
}
|
||||
|
||||
// TODO: group chats
|
||||
pub struct Channel {}
|
||||
// pub enum Chat {
|
||||
// Direct(DirectChat),
|
||||
// Channel(Channel),
|
||||
// }
|
||||
// pub struct Channel {}
|
||||
|
|
|
@ -29,6 +29,7 @@ mod connection;
|
|||
mod error;
|
||||
mod presence;
|
||||
mod roster;
|
||||
mod user;
|
||||
|
||||
pub struct Luz {
|
||||
receiver: mpsc::Receiver<CommandMessage>,
|
||||
|
@ -269,9 +270,10 @@ impl LuzHandle {
|
|||
}
|
||||
|
||||
pub enum CommandMessage {
|
||||
/// connect to XMPP chat server. gets roster and
|
||||
// TODO: login invisible xep-0186
|
||||
/// connect to XMPP chat server. gets roster and publishes initial presence.
|
||||
Connect,
|
||||
/// disconnect from XMPP chat server.
|
||||
/// disconnect from XMPP chat server, sending unavailable presence then closing stream.
|
||||
Disconnect,
|
||||
/// get the roster. if offline, retreive cached version from database. should be stored in application memory
|
||||
GetRoster,
|
||||
|
|
|
@ -3,9 +3,12 @@ use std::collections::HashSet;
|
|||
use jid::JID;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::user::User;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Contact {
|
||||
// jid is the id used to reference everything, but not the primary key
|
||||
user: User,
|
||||
jid: JID,
|
||||
subscription: Subscription,
|
||||
/// client user defined name
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
use jid::JID;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct User {
|
||||
jid: JID,
|
||||
cached_status: Option<String>,
|
||||
}
|
Loading…
Reference in New Issue