From 39012c6b17073f6933a5ead8beed64df555f7348 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Fri, 6 May 2022 22:45:27 -0700 Subject: converting functions to activitypub object functions --- util/util.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'util/util.go') diff --git a/util/util.go b/util/util.go index 0ffbf01..0126556 100644 --- a/util/util.go +++ b/util/util.go @@ -2,11 +2,14 @@ package util import ( "crypto/sha256" + "database/sql" "encoding/hex" "fmt" + "io/ioutil" "mime/multipart" "net/http" "os" + "path" "regexp" "strings" @@ -261,3 +264,41 @@ func CreatedNeededDirectories() { os.MkdirAll("./pem/board", 0700) } } + +func LoadThemes() { + // get list of themes + themes, err := ioutil.ReadDir("./static/css/themes") + if err != nil { + panic(err) + } + + for _, f := range themes { + if e := path.Ext(f.Name()); e == ".css" { + config.Themes = append(config.Themes, strings.TrimSuffix(f.Name(), e)) + } + } +} + +func GetBoardAuth(board string) ([]string, error) { + var auth []string + + query := `select type from actorauth where board=$1` + + var rows *sql.Rows + var err error + if rows, err = config.DB.Query(query, board); err != nil { + return auth, err + } + + defer rows.Close() + for rows.Next() { + var _type string + if err := rows.Scan(&_type); err != nil { + return auth, err + } + + auth = append(auth, _type) + } + + return auth, nil +} -- cgit v1.2.3