2020-01-10 18:59:01 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS chats (
|
|
|
|
id VARCHAR PRIMARY KEY ON CONFLICT REPLACE,
|
|
|
|
name VARCHAR NOT NULL,
|
|
|
|
color VARCHAR NOT NULL DEFAULT '#a187d5',
|
|
|
|
type INT NOT NULL,
|
|
|
|
active BOOLEAN NOT NULL DEFAULT TRUE,
|
|
|
|
timestamp INT NOT NULL,
|
|
|
|
deleted_at_clock_value INT NOT NULL DEFAULT 0,
|
|
|
|
public_key BLOB,
|
|
|
|
unviewed_message_count INT NOT NULL DEFAULT 0,
|
|
|
|
last_clock_value INT NOT NULL DEFAULT 0,
|
|
|
|
last_message BLOB,
|
|
|
|
members BLOB,
|
|
|
|
membership_updates BLOB
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE contacts (
|
|
|
|
id TEXT PRIMARY KEY ON CONFLICT REPLACE,
|
|
|
|
address TEXT NOT NULL,
|
|
|
|
name TEXT NOT NULL,
|
|
|
|
ens_verified BOOLEAN DEFAULT FALSE,
|
|
|
|
ens_verified_at INT NOT NULL DEFAULT 0,
|
|
|
|
alias TEXT NOT NULL,
|
|
|
|
identicon TEXT NOT NULL,
|
|
|
|
photo TEXT NOT NULL,
|
|
|
|
last_updated INT NOT NULL DEFAULT 0,
|
|
|
|
system_tags BLOB,
|
|
|
|
device_info BLOB,
|
|
|
|
tribute_to_talk TEXT NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
-- It's important that this table has rowid as we rely on it
|
|
|
|
-- when implementing infinite-scroll.
|
2019-11-21 16:19:22 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS user_messages (
|
2020-01-10 18:59:01 +00:00
|
|
|
id VARCHAR PRIMARY KEY ON CONFLICT REPLACE,
|
|
|
|
whisper_timestamp INTEGER NOT NULL,
|
|
|
|
source TEXT NOT NULL,
|
|
|
|
destination BLOB,
|
|
|
|
text VARCHAR NOT NULL,
|
|
|
|
content_type INT NOT NULL,
|
|
|
|
username VARCHAR,
|
|
|
|
timestamp INT NOT NULL,
|
2019-11-21 16:19:22 +00:00
|
|
|
chat_id VARCHAR NOT NULL,
|
2020-01-10 18:59:01 +00:00
|
|
|
local_chat_id VARCHAR NOT NULL,
|
|
|
|
hide BOOLEAN DEFAULT FALSE,
|
|
|
|
response_to VARCHAR,
|
Move to protobuf for Message type (#1706)
* Use a single Message type `v1/message.go` and `message.go` are the same now, and they embed `protobuf.ChatMessage`
* Use `SendChatMessage` for sending chat messages, this is basically the old `Send` but a bit more flexible so we can send different message types (stickers,commands), and not just text.
* Remove dedup from services/shhext. Because now we process in status-protocol, dedup makes less sense, as those messages are going to be processed anyway, so removing for now, we can re-evaluate if bringing it to status-go or not.
* Change the various retrieveX method to a single one:
`RetrieveAll` will be processing those messages that it can process (Currently only `Message`), and return the rest in `RawMessages` (still transit). The format for the response is:
`Chats`: -> The chats updated by receiving the message
`Messages`: -> The messages retrieved (already matched to a chat)
`Contacts`: -> The contacts updated by the messages
`RawMessages` -> Anything else that can't be parsed, eventually as we move everything to status-protocol-go this will go away.
2019-12-05 16:25:34 +00:00
|
|
|
message_type INT,
|
2020-01-10 18:59:01 +00:00
|
|
|
clock_value INT NOT NULL,
|
|
|
|
seen BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
outgoing_status VARCHAR,
|
|
|
|
parsed_text BLOB,
|
|
|
|
raw_payload BLOB,
|
|
|
|
sticker_pack INT,
|
|
|
|
sticker_hash VARCHAR,
|
|
|
|
command_id VARCHAR,
|
|
|
|
command_value VARCHAR,
|
|
|
|
command_address VARCHAR,
|
|
|
|
command_from VARCHAR,
|
|
|
|
command_contract VARCHAR,
|
|
|
|
command_transaction_hash VARCHAR,
|
|
|
|
command_signature BLOB,
|
|
|
|
command_state INT
|
2019-11-21 16:19:22 +00:00
|
|
|
);
|
|
|
|
|
2020-01-10 18:59:01 +00:00
|
|
|
CREATE INDEX idx_source ON user_messages(source);
|
|
|
|
CREATE INDEX idx_search_by_chat_id ON user_messages(
|
|
|
|
substr('0000000000000000000000000000000000000000000000000000000000000000' || clock_value, -64, 64) || id, chat_id, hide
|
|
|
|
);
|
2019-11-21 16:19:22 +00:00
|
|
|
|
2020-01-10 18:59:01 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS raw_messages (
|
|
|
|
id VARCHAR PRIMARY KEY ON CONFLICT REPLACE,
|
|
|
|
local_chat_id VARCHAR NOT NULL,
|
|
|
|
last_sent INT NOT NULL,
|
|
|
|
send_count INT NOT NULL,
|
|
|
|
sent BOOLEAN DEFAULT FALSE,
|
|
|
|
resend_automatically BOOLEAN DEFAULT FALSE,
|
|
|
|
message_type INT,
|
|
|
|
recipients BLOB,
|
|
|
|
payload BLOB);
|
2019-11-21 16:19:22 +00:00
|
|
|
|
2020-01-10 18:59:01 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS messenger_transactions_to_validate (
|
|
|
|
message_id VARCHAR,
|
|
|
|
command_id VARCHAR NOT NULL,
|
|
|
|
transaction_hash VARCHAR PRIMARY KEY,
|
|
|
|
retry_count INT,
|
|
|
|
first_seen INT,
|
|
|
|
signature BLOB NOT NULL,
|
|
|
|
to_validate BOOLEAN DEFAULT TRUE,
|
|
|
|
public_key BLOB);
|
|
|
|
|
|
|
|
CREATE INDEX idx_messenger_transaction_to_validate ON messenger_transactions_to_validate(to_validate);
|