Added avatar identifiers and servers table
This commit is contained in:
parent
698740e20a
commit
d748735ded
@ -12,4 +12,3 @@ Look at the exported API and cry...
|
||||
|
||||
## Other option
|
||||
GOOS=android GOARCH=arm64 go build -buildmode=c-archive -o libmeow.a
|
||||
|
||||
|
@ -16,6 +16,7 @@ const maxHiddenCount = 30
|
||||
|
||||
type Identity struct {
|
||||
Nickname string `json:"nickname,omitempty"`
|
||||
DefaultAvatarUuid string `json:"default_avatar_uuid,omitempty"`
|
||||
RootKp meowlib.KeyPair `json:"id_kp,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Peers PeerList `json:"peers,omitempty"`
|
||||
|
@ -31,6 +31,7 @@ type Peer struct {
|
||||
OnionMode bool `json:"onion_mode,omitempty"`
|
||||
LastMessage time.Time `json:"last_message,omitempty"`
|
||||
DbIds []string `json:"db_ids,omitempty"`
|
||||
AvatarUuid string `json:"avatar_uid,omitempty"`
|
||||
dbPassword string
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ func StoreMessage(peer *Peer, usermessage *meowlib.UserMessage, password string)
|
||||
file.Close()
|
||||
peer.DbIds = append(peer.DbIds, dbid)
|
||||
sqliteDatabase, _ := sql.Open("sqlite3", filepath.Join(GetConfig().StoragePath, dbid+GetConfig().DbSuffix)) // Open the created SQLite File
|
||||
err = createTable(sqliteDatabase)
|
||||
err = createMessageTable(sqliteDatabase)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -150,7 +150,7 @@ func getMessageCount(dbid string) (int, error) {
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func createTable(db *sql.DB) error {
|
||||
func createMessageTable(db *sql.DB) error {
|
||||
createMessageTableSQL := `CREATE TABLE message (
|
||||
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"m" BLOB);` // SQL Statement for Create Table
|
||||
@ -161,3 +161,24 @@ func createTable(db *sql.DB) error {
|
||||
statement.Exec() // Execute SQL Statements
|
||||
return nil
|
||||
}
|
||||
|
||||
func createServerTable(db *sql.DB) error {
|
||||
createServerTableSQL := `CREATE TABLE servers (
|
||||
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"country" varchar(2),
|
||||
"public" bool,
|
||||
"uptime" int,
|
||||
"bandwith" float,
|
||||
"load" float,
|
||||
"url" varchar(2000)
|
||||
"name" varchar(255);
|
||||
"description" varchar(5000)
|
||||
"publickey" varchar(10000)
|
||||
)` // SQL Statement for Create Table
|
||||
statement, err := db.Prepare(createServerTableSQL) // Prepare SQL Statement
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
statement.Exec() // Execute SQL Statements
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user