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.
|
-- TODO: avatar, nick, etc.
|
||||||
create table user(
|
create table user(
|
||||||
jid jid primary key,
|
jid jid primary key,
|
||||||
|
-- can receive presence status from non-contacts
|
||||||
cached_status text,
|
cached_status text,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -36,9 +37,11 @@ create table groups_roster(
|
||||||
);
|
);
|
||||||
|
|
||||||
-- chat includes reference to user jid chat is with
|
-- 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 (
|
create table chats (
|
||||||
id uuid primary key,
|
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.
|
-- messages include reference to chat they are in, and who sent them.
|
||||||
|
@ -46,6 +49,7 @@ create table messages (
|
||||||
id uuid primary key,
|
id uuid primary key,
|
||||||
body text,
|
body text,
|
||||||
chat_id uuid not null,
|
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,
|
from jid not null,
|
||||||
-- TODO: read bool not null,
|
-- TODO: read bool not null,
|
||||||
foreign key(chat_id) references chats(id),
|
foreign key(chat_id) references chats(id),
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::roster::Contact;
|
use crate::{roster::Contact, user::User};
|
||||||
|
|
||||||
pub enum Chat {
|
|
||||||
Direct(DM),
|
|
||||||
Channel(Channel),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
// contains full contact information
|
// contains full user information
|
||||||
from: Contact,
|
from: User,
|
||||||
// TODO: rich text, other contents, threads
|
// TODO: rich text, other contents, threads
|
||||||
body: Body,
|
body: Body,
|
||||||
}
|
}
|
||||||
|
@ -21,10 +16,15 @@ pub struct Body {
|
||||||
body: String,
|
body: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DM {
|
pub struct Chat {
|
||||||
contact: Contact,
|
id: Uuid,
|
||||||
|
user: User,
|
||||||
message_history: Vec<Message>,
|
message_history: Vec<Message>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: group chats
|
// 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 error;
|
||||||
mod presence;
|
mod presence;
|
||||||
mod roster;
|
mod roster;
|
||||||
|
mod user;
|
||||||
|
|
||||||
pub struct Luz {
|
pub struct Luz {
|
||||||
receiver: mpsc::Receiver<CommandMessage>,
|
receiver: mpsc::Receiver<CommandMessage>,
|
||||||
|
@ -269,9 +270,10 @@ impl LuzHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum CommandMessage {
|
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,
|
Connect,
|
||||||
/// disconnect from XMPP chat server.
|
/// disconnect from XMPP chat server, sending unavailable presence then closing stream.
|
||||||
Disconnect,
|
Disconnect,
|
||||||
/// get the roster. if offline, retreive cached version from database. should be stored in application memory
|
/// get the roster. if offline, retreive cached version from database. should be stored in application memory
|
||||||
GetRoster,
|
GetRoster,
|
||||||
|
|
|
@ -3,9 +3,12 @@ use std::collections::HashSet;
|
||||||
use jid::JID;
|
use jid::JID;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::user::User;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Contact {
|
pub struct Contact {
|
||||||
// jid is the id used to reference everything, but not the primary key
|
// jid is the id used to reference everything, but not the primary key
|
||||||
|
user: User,
|
||||||
jid: JID,
|
jid: JID,
|
||||||
subscription: Subscription,
|
subscription: Subscription,
|
||||||
/// client user defined name
|
/// 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