summaryrefslogtreecommitdiff
path: root/pkg/idec/idec.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/idec/idec.go')
-rw-r--r--pkg/idec/idec.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/pkg/idec/idec.go b/pkg/idec/idec.go
new file mode 100644
index 0000000..0692d65
--- /dev/null
+++ b/pkg/idec/idec.go
@@ -0,0 +1,51 @@
+package idec
+
+import (
+ "errors"
+
+ "gitrepo.ru/neonxp/idecnode/pkg/config"
+ "go.etcd.io/bbolt"
+)
+
+var Features = []string{"list.txt", "blacklist.txt", "u/e", "u/m", "x/c", "m", "e"}
+
+var (
+ ErrUserNotFound = errors.New("user not found")
+ ErrMessageNotFound = errors.New("message not found")
+ ErrFailedSaveMessage = errors.New("- failed save message")
+ ErrWrongMessageFormat = errors.New("- wrong message format")
+ ErrNoAuth = errors.New("no auth - wrong authstring")
+)
+
+const (
+ msgBucket = "_msg"
+ points = "_points"
+)
+
+type IDEC struct {
+ config *config.Config
+ db *bbolt.DB
+}
+
+func New(config *config.Config) (*IDEC, error) {
+ db, err := bbolt.Open(config.Store, 0o600, nil)
+ if err != nil {
+ return nil, err
+ }
+
+ return &IDEC{
+ config: config,
+ db: db,
+ }, nil
+}
+
+func (i *IDEC) Close() error {
+ return i.db.Close()
+}
+
+func max(x, y int) int {
+ if x > y {
+ return x
+ }
+ return y
+}