From d748735deddcbe5fa45a4b508efc079033afbefb Mon Sep 17 00:00:00 2001 From: ycc Date: Thu, 27 Jul 2023 10:44:09 +0200 Subject: [PATCH] Added avatar identifiers and servers table --- README.md | 1 - client/identity.go | 1 + client/peer.go | 1 + client/storage.go | 25 +++++++++++++++++++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 70b6562..c6c9cfb 100644 --- a/README.md +++ b/README.md @@ -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 - diff --git a/client/identity.go b/client/identity.go index 917565a..1978aa3 100644 --- a/client/identity.go +++ b/client/identity.go @@ -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"` diff --git a/client/peer.go b/client/peer.go index 87fdeac..cd19eed 100644 --- a/client/peer.go +++ b/client/peer.go @@ -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 } diff --git a/client/storage.go b/client/storage.go index 8f6e114..32bac11 100644 --- a/client/storage.go +++ b/client/storage.go @@ -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 +}