database

package
v0.0.0-...-66c81c8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFriend

func AddFriend(friendCode string, id int) error

Handles adding a friend to the users friend list

func AreMutualFriends

func AreMutualFriends(user_one_id int, user_two_id int) bool

AreMutualFriends determines if two users are mutual friends

func CreateAccount

func CreateAccount(username string, password string) error

Creates an account in the database uuid is unique to the computer, and is used on startup to indentify the device

func DeactivateSession

func DeactivateSession(id int) error

Deactivates the session of a single user

func DeleteAccount

func DeleteAccount(id int) error

Removes all account information for a given user and deletes all rows that they are present in, including sent

func DeleteFriend

func DeleteFriend(id int, username string) error

Removes a friend from users friend list

func DeleteTransaction

func DeleteTransaction(id int, filename string) error

Deletes a transaction record based on the given id

func GetConn

func GetConn() (*pgx.Conn, error)

Create target connection for the database

func GetCurrentId

func GetCurrentId() int

Returns currently logged in users id

func GetUserFriendCode

func GetUserFriendCode(id int) (string, error)

Retrieves a user's freind code based on their name, which is passed in

func GetUserID

func GetUserID(name string) (int, error)

Retrieves a user's id based on their name, which is passed in

func GetUserNameByID

func GetUserNameByID(id int) (string, error)

Retrieves a user's name based on their id, which is passed in

func HashInfo

func HashInfo(text string) string

Hashes using the SHA256 package

func InitializeDatabase

func InitializeDatabase() error

Inits all of the tables for the database

func InsertPublicKey

func InsertPublicKey(id int, key []byte) error

Inserts the public key into the userkey table

func InsertRSA

func InsertRSA(nonce []byte, key []byte, id int) error

Inserts the encrypted nonce and key into rsa table

func IsFriend

func IsFriend(user_one_id int, user_two_id int) bool

Checks if user one is friends with user two

func Login

func Login(username string, password string) error

Sets the user who is loggin in

func PerformTransaction

func PerformTransaction(from_user_id int, user_to string, filename string) (int, error)

Enters the information of a transaction to the database for later referal

func RetrievePublicKey

func RetrievePublicKey(id int) ([]byte, error)

Retrieves the key from the database that is used to encrypt the file

func RetrieveRSA

func RetrieveRSA(user int, file string) ([]byte, []byte, error)

Returns the RSA encrypted nonce and key

func SetActiveSession

func SetActiveSession() (int, error)

Returns the current users id and sets the session

func UserCanViewTransaction

func UserCanViewTransaction(id int, filename string) bool

Checks if a user has the right to view a transaction

Types

type Friend

type Friend struct {
	Nickname   string
	Username   string
	FriendCode string
}

func GetFriendsList

func GetFriendsList(id int) ([]Friend, error)

Retrieves a list of friends for a given user

type Sql

type Sql struct {
	Host     string
	Port     uint16
	Database string
	User     string
	Password string
}

type Transaction

type Transaction struct {
	From_user string
	File_name string
}

func GetPendingTransfers

func GetPendingTransfers(id int) ([]Transaction, error)

retrieves pending file transfer requests for a certain user

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL