init
This commit is contained in:
commit
31aa06c526
34
.gitignore
vendored
Normal file
34
.gitignore
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
# If you prefer the allow list template instead of the deny list, see community template:
|
||||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||
#
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Code coverage profiles and other test artifacts
|
||||
*.out
|
||||
coverage.*
|
||||
*.coverprofile
|
||||
profile.cov
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
go.work.sum
|
||||
|
||||
# env file
|
||||
.env
|
||||
|
||||
# Editor/IDE
|
||||
# .idea/
|
||||
.vscode/
|
||||
|
||||
server
|
33
Readme.md
Normal file
33
Readme.md
Normal file
@ -0,0 +1,33 @@
|
||||
# Chat server
|
||||
|
||||
## Goals
|
||||
|
||||
- manage sessions
|
||||
- [ ] login
|
||||
- [ ] register
|
||||
- [ ] logout
|
||||
- edit users
|
||||
- [ ] status
|
||||
- [ ] bio
|
||||
- [ ] profile picture
|
||||
- [ ] provide user info
|
||||
- manage rights and roles
|
||||
- [ ] edit roles
|
||||
- [ ] bind roles to users
|
||||
- manage messages
|
||||
- [ ] send
|
||||
- [ ] alert
|
||||
- [ ] query
|
||||
- files
|
||||
- [ ] upload
|
||||
- [ ] serve
|
||||
|
||||
## Structure
|
||||
|
||||
- Valkey
|
||||
- sessions tokens
|
||||
- new messages
|
||||
- Postgres
|
||||
- longterm message storage
|
||||
- user info
|
||||
- roles and rights
|
19
api/auth.go
Normal file
19
api/auth.go
Normal file
@ -0,0 +1,19 @@
|
||||
package api
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func isLoggedIn(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func register(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func login(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func logout(c *gin.Context) {
|
||||
|
||||
}
|
28
api/endpoints.go
Normal file
28
api/endpoints.go
Normal file
@ -0,0 +1,28 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Listen(address string, base string) error {
|
||||
router := gin.Default()
|
||||
|
||||
api := router.Group(base)
|
||||
|
||||
auth := api.Group("auth")
|
||||
auth.POST("register", register)
|
||||
auth.POST("login", login)
|
||||
auth.GET("logout", isLoggedIn, logout)
|
||||
|
||||
server := &http.Server{
|
||||
Addr: address,
|
||||
Handler: router,
|
||||
ReadTimeout: 10 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
}
|
||||
|
||||
return server.ListenAndServe()
|
||||
}
|
61
config/config.go
Normal file
61
config/config.go
Normal file
@ -0,0 +1,61 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/kouhin/envflag"
|
||||
"github.com/valkey-io/valkey-go"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Database struct {
|
||||
Host string
|
||||
Port uint
|
||||
User string
|
||||
Password string
|
||||
DBname string
|
||||
}
|
||||
|
||||
Valkey valkey.ClientOption
|
||||
|
||||
API struct {
|
||||
Address string
|
||||
Base string
|
||||
TokenLife int
|
||||
}
|
||||
}
|
||||
|
||||
var config *Config
|
||||
|
||||
func GetConfig() *Config {
|
||||
if len(config.Valkey.InitAddress) == 0 {
|
||||
config.Valkey.InitAddress = make([]string, 1)
|
||||
}
|
||||
|
||||
if config == nil {
|
||||
config = &Config{}
|
||||
|
||||
flag.StringVar(&config.Database.Host, "db-host", "db", "database host")
|
||||
flag.UintVar(&config.Database.Port, "db-port", 5432, "database port")
|
||||
flag.StringVar(&config.Database.User, "db-user", "admin", "database user")
|
||||
flag.StringVar(&config.Database.Password, "db-password", "admin", "database password")
|
||||
flag.StringVar(&config.Database.DBname, "db-name", "szoe", "database name")
|
||||
|
||||
flag.StringVar(&config.Valkey.InitAddress[0], "valkey-address", "valkey:6379", "Valkey server address")
|
||||
flag.StringVar(&config.Valkey.Username, "valkey-username", "", "Valkey username")
|
||||
flag.StringVar(&config.Valkey.Password, "valkey-password", "", "Valkey password")
|
||||
flag.IntVar(&config.Valkey.SelectDB, "valkey-db", 0, "Valkey database number")
|
||||
|
||||
flag.StringVar(&config.API.Address, "api-address", ":5000", "API address")
|
||||
flag.StringVar(&config.API.Base, "api-base", "", "API path base")
|
||||
flag.IntVar(&config.API.TokenLife, "api-token-life", 24*60*60, "API login token lifetime in seconds")
|
||||
|
||||
if err := envflag.Parse(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
7
controller/Factory.go
Normal file
7
controller/Factory.go
Normal file
@ -0,0 +1,7 @@
|
||||
package controller
|
||||
|
||||
func MakeUserController() (UserController, error) {
|
||||
userController := &UserController{}
|
||||
err := userController.init()
|
||||
return *userController, err
|
||||
}
|
5
controller/IController.go
Normal file
5
controller/IController.go
Normal file
@ -0,0 +1,5 @@
|
||||
package controller
|
||||
|
||||
type IController interface {
|
||||
init() error
|
||||
}
|
49
controller/UserController.go
Normal file
49
controller/UserController.go
Normal file
@ -0,0 +1,49 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.tek.govt.hu/dowerx/chat/server/dao"
|
||||
"git.tek.govt.hu/dowerx/chat/server/model"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
type UserController struct {
|
||||
userDAO dao.IUserDAO
|
||||
}
|
||||
|
||||
const (
|
||||
MIN_USERNAME_LENGTH int = 3
|
||||
MIN_PASSWORD_LENGTH int = 6
|
||||
HASH_COST int = bcrypt.DefaultCost
|
||||
)
|
||||
|
||||
func (c *UserController) init() error {
|
||||
userDAO, err := dao.MakeUserDAO()
|
||||
c.userDAO = userDAO
|
||||
return err
|
||||
}
|
||||
|
||||
func (c UserController) Register(username string, password string, repeatPassword string) error {
|
||||
if len(username) < MIN_USERNAME_LENGTH {
|
||||
return errors.New("username too short")
|
||||
}
|
||||
if len(password) < MIN_PASSWORD_LENGTH {
|
||||
return errors.New("username too short")
|
||||
}
|
||||
|
||||
if password != repeatPassword {
|
||||
return errors.New("passwords don't match")
|
||||
}
|
||||
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(password), HASH_COST)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.userDAO.Create(model.User{
|
||||
Username: username,
|
||||
PasswordHash: string(hash),
|
||||
})
|
||||
}
|
9
dao/Factory.go
Normal file
9
dao/Factory.go
Normal file
@ -0,0 +1,9 @@
|
||||
package dao
|
||||
|
||||
import "git.tek.govt.hu/dowerx/chat/server/dao/postgres"
|
||||
|
||||
func MakeUserDAO() (IUserDAO, error) {
|
||||
dao := &postgres.UserDAOPG{}
|
||||
err := dao.Init()
|
||||
return dao, err
|
||||
}
|
5
dao/IDAO.go
Normal file
5
dao/IDAO.go
Normal file
@ -0,0 +1,5 @@
|
||||
package dao
|
||||
|
||||
type IDAO interface {
|
||||
Init() error
|
||||
}
|
6
dao/ISessionDAO.go
Normal file
6
dao/ISessionDAO.go
Normal file
@ -0,0 +1,6 @@
|
||||
package dao
|
||||
|
||||
type ISessionDAO interface {
|
||||
Set(token string, id int) error
|
||||
Get(token string) (int, error)
|
||||
}
|
11
dao/IUserDAO.go
Normal file
11
dao/IUserDAO.go
Normal file
@ -0,0 +1,11 @@
|
||||
package dao
|
||||
|
||||
import "git.tek.govt.hu/dowerx/chat/server/model"
|
||||
|
||||
type IUserDAO interface {
|
||||
Create(user model.User) error
|
||||
Read(user model.User) (model.User, error)
|
||||
List() ([]model.User, error)
|
||||
Update(user model.User) error
|
||||
Delete(user model.User) error
|
||||
}
|
23
dao/postgres/Connection.go
Normal file
23
dao/postgres/Connection.go
Normal file
@ -0,0 +1,23 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.tek.govt.hu/dowerx/chat/server/config"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
var db *sqlx.DB
|
||||
|
||||
func getDatabase() (*sqlx.DB, error) {
|
||||
if db == nil {
|
||||
cfg := config.GetConfig()
|
||||
newDB, err := sqlx.Connect("postgres", fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", cfg.Database.Host, cfg.Database.Port, cfg.Database.User, cfg.Database.Password, cfg.Database.DBname))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db = newDB
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
81
dao/postgres/UserDAO.go
Normal file
81
dao/postgres/UserDAO.go
Normal file
@ -0,0 +1,81 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.tek.govt.hu/dowerx/chat/server/model"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
type UserDAOPG struct {
|
||||
pgDAO
|
||||
}
|
||||
|
||||
// Create a new user
|
||||
func (d UserDAOPG) Create(user model.User) error {
|
||||
_, err := d.db.NamedExec(`call add_user(:username, :password_hash)`, &user)
|
||||
return err
|
||||
}
|
||||
|
||||
// Read returns a user by ID if ID != 0, else by Username
|
||||
func (d UserDAOPG) Read(user model.User) (model.User, error) {
|
||||
var rows *sqlx.Rows
|
||||
var err error
|
||||
if user.ID != 0 {
|
||||
rows, err = d.db.NamedQuery(`select * from "user" where "id" = :id`, &user)
|
||||
} else {
|
||||
rows, err = d.db.NamedQuery(`select * from "user" where "username" = :username`, &user)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return user, err
|
||||
}
|
||||
|
||||
if !rows.Next() {
|
||||
return user, errors.New("no such user")
|
||||
}
|
||||
|
||||
err = rows.Scan(&user)
|
||||
return user, err
|
||||
}
|
||||
|
||||
// List all users
|
||||
func (d UserDAOPG) List() ([]model.User, error) {
|
||||
rows, err := d.db.Query(`select * from "user" order by "username"`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
users := make([]model.User, 0)
|
||||
|
||||
for rows.Next() {
|
||||
user := model.User{}
|
||||
|
||||
err = rows.Scan(&user)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
users = append(users, user)
|
||||
}
|
||||
|
||||
return users, err
|
||||
}
|
||||
|
||||
// Update sets all the fields of the User with the given ID
|
||||
func (d UserDAOPG) Update(user model.User) error {
|
||||
_, err := d.db.NamedExec(`update "user" set "username" = :username, "password_hash" = :password_hash, "status" = :status, "picture" = :picture, "bio" = :bio where "id" = :id`, &user)
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete removes a user by ID if ID != 0, else by Username
|
||||
func (d UserDAOPG) Delete(user model.User) error {
|
||||
var err error
|
||||
if user.ID != 0 {
|
||||
_, err = d.db.NamedExec(`delete from "user" where "id" = :id`, &user)
|
||||
} else {
|
||||
_, err = d.db.NamedExec(`delete from "user" where "username" = :username`, &user)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
15
dao/postgres/pgDAO.go
Normal file
15
dao/postgres/pgDAO.go
Normal file
@ -0,0 +1,15 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
type pgDAO struct {
|
||||
db *sqlx.DB
|
||||
}
|
||||
|
||||
func (d *pgDAO) Init() error {
|
||||
conn, err := getDatabase()
|
||||
d.db = conn
|
||||
return err
|
||||
}
|
42
go.mod
Normal file
42
go.mod
Normal file
@ -0,0 +1,42 @@
|
||||
module git.tek.govt.hu/dowerx/chat/server
|
||||
|
||||
go 1.23.0
|
||||
|
||||
require (
|
||||
github.com/jmoiron/sqlx v1.4.0
|
||||
github.com/kouhin/envflag v0.0.0-20150818174321-0e9a86061649
|
||||
github.com/valkey-io/valkey-go v1.0.60
|
||||
golang.org/x/crypto v0.38.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bytedance/sonic v1.11.6 // indirect
|
||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
golang.org/x/arch v0.8.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/text v0.25.0 // indirect
|
||||
google.golang.org/protobuf v1.34.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.10.1
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
)
|
89
go.sum
Normal file
89
go.sum
Normal file
@ -0,0 +1,89 @@
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
|
||||
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
|
||||
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
|
||||
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kouhin/envflag v0.0.0-20150818174321-0e9a86061649 h1:l95EUBxc0iMtMeam3pHFb9jko9ntaLYe2Nc+2evKElM=
|
||||
github.com/kouhin/envflag v0.0.0-20150818174321-0e9a86061649/go.mod h1:BT0PpXv8Y4EL/WUsQmYsQ2FSB9HwQXIuvY+pElZVdFg=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/valkey-io/valkey-go v1.0.60 h1:idh959D20H5n7D/kwEdTKNaMn5+4HpZTn7bLXnAhQIw=
|
||||
github.com/valkey-io/valkey-go v1.0.60/go.mod h1:bHmwjIEOrGq/ubOJfh5uMRs7Xj6mV3mQ/ZXUbmqpjqY=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
||||
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
|
||||
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
||||
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
13
main.go
Normal file
13
main.go
Normal file
@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import "git.tek.govt.hu/dowerx/chat/server/controller"
|
||||
|
||||
func main() {
|
||||
userController, err := controller.MakeUserController()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
userController.Register("", "", "")
|
||||
}
|
6
model/Channel.go
Normal file
6
model/Channel.go
Normal file
@ -0,0 +1,6 @@
|
||||
package model
|
||||
|
||||
type Channel struct {
|
||||
ID int
|
||||
Name string
|
||||
}
|
11
model/Message.go
Normal file
11
model/Message.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type Message struct {
|
||||
ID int
|
||||
Sender User
|
||||
Channel Channel
|
||||
Time time.Time
|
||||
Content string
|
||||
}
|
10
model/Right.go
Normal file
10
model/Right.go
Normal file
@ -0,0 +1,10 @@
|
||||
package model
|
||||
|
||||
type Right string
|
||||
|
||||
const (
|
||||
RightRead = "R"
|
||||
RightWrite = "W"
|
||||
RightReadWrite = "RW"
|
||||
RightAdmin = "A"
|
||||
)
|
10
model/User.go
Normal file
10
model/User.go
Normal file
@ -0,0 +1,10 @@
|
||||
package model
|
||||
|
||||
type User struct {
|
||||
ID int `db:"id"`
|
||||
Username string `db:"username"`
|
||||
PasswordHash string `db:"password_hash"`
|
||||
Status string `db:"status"`
|
||||
Picture string `db:"picture"`
|
||||
Bio string `db:"bio"`
|
||||
}
|
Loading…
Reference in New Issue
Block a user