diff --git a/README.md b/README.md index 6a4817e1..77d8b9a0 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ cd notify.moe go mod download make tools make assets -go build +make server +make db ./notify.moe ``` diff --git a/README.src.md b/README.src.md index a3038856..b465578b 100644 --- a/README.src.md +++ b/README.src.md @@ -17,7 +17,8 @@ cd notify.moe go mod download make tools make assets -go build +make server +make db ./notify.moe ``` diff --git a/arn/Database.go b/arn/Database.go index ca62fe7e..ea1647ef 100644 --- a/arn/Database.go +++ b/arn/Database.go @@ -1,6 +1,8 @@ package arn import ( + "path" + "github.com/aerogo/api" "github.com/aerogo/nano" "github.com/animenotifier/kitsu" @@ -9,7 +11,8 @@ import ( // Node represents the database node. var Node = nano.New(nano.Configuration{ - Port: 5000, + Port: 5000, + Directory: path.Join(Root, "db"), }) // DB is the main database client. @@ -67,5 +70,5 @@ var Kitsu = Node.Namespace("kitsu").RegisterTypes( (*kitsu.Character)(nil), ) -// API ... +// API is used to install the REST API. var API = api.New("/api/", DB) diff --git a/arn/DraftIndex.go b/arn/DraftIndex.go index 81743f45..5c0c7528 100644 --- a/arn/DraftIndex.go +++ b/arn/DraftIndex.go @@ -24,8 +24,8 @@ func NewDraftIndex(userID UserID) *DraftIndex { } } -// GetID gets the ID for the given type name. -func (index *DraftIndex) GetID(typeName string) (string, error) { +// DraftID gets the ID for the given type name. +func (index *DraftIndex) DraftID(typeName string) (string, error) { v := reflect.ValueOf(index).Elem() fieldValue := v.FieldByName(typeName + "ID") @@ -36,8 +36,8 @@ func (index *DraftIndex) GetID(typeName string) (string, error) { return fieldValue.String(), nil } -// SetID sets the ID for the given type name. -func (index *DraftIndex) SetID(typeName string, id string) error { +// SetDraftID sets the ID for the given type name. +func (index *DraftIndex) SetDraftID(typeName string, id string) error { v := reflect.ValueOf(index).Elem() fieldValue := v.FieldByName(typeName + "ID") @@ -49,6 +49,11 @@ func (index *DraftIndex) SetID(typeName string, id string) error { return nil } +// GetID returns the ID. +func (index *DraftIndex) GetID() string { + return index.UserID +} + // GetDraftIndex ... func GetDraftIndex(id string) (*DraftIndex, error) { obj, err := DB.Get("DraftIndex", id) diff --git a/arn/DraftIndexAPI.go b/arn/DraftIndexAPI.go index 46485565..952ac6a6 100644 --- a/arn/DraftIndexAPI.go +++ b/arn/DraftIndexAPI.go @@ -4,7 +4,8 @@ import "github.com/aerogo/api" // Force interface implementations var ( - _ api.Savable = (*DraftIndex)(nil) + _ Identifiable = (*DraftIndex)(nil) + _ api.Savable = (*DraftIndex)(nil) ) // Save saves the index in the database. diff --git a/arn/Publishable.go b/arn/Publishable.go index f84436d4..2d7aa58f 100644 --- a/arn/Publishable.go +++ b/arn/Publishable.go @@ -78,7 +78,7 @@ func publish(draft Publishable) error { return err } - currentDraftID, _ := draftIndex.GetID(typ.Name()) + currentDraftID, _ := draftIndex.DraftID(typ.Name()) if currentDraftID != draft.GetID() { return errors.New(typ.Name() + " draft doesn't exist in the user draft index") @@ -86,7 +86,7 @@ func publish(draft Publishable) error { // Publish the object draft.SetIsDraft(false) - err = draftIndex.SetID(typ.Name(), "") + err = draftIndex.SetDraftID(typ.Name(), "") if err != nil { return err @@ -113,14 +113,14 @@ func unpublish(draft Publishable) error { return err } - draftIndexID, _ := draftIndex.GetID(typ.Name()) + draftIndexID, _ := draftIndex.DraftID(typ.Name()) if draftIndexID != "" { return errors.New("You still have an unfinished draft") } draft.SetIsDraft(true) - err = draftIndex.SetID(typ.Name(), draft.GetID()) + err = draftIndex.SetDraftID(typ.Name(), draft.GetID()) if err != nil { return err diff --git a/arn/UserFollows.go b/arn/UserFollows.go index d5a239fa..6d6a4a20 100644 --- a/arn/UserFollows.go +++ b/arn/UserFollows.go @@ -107,6 +107,11 @@ func (list *UserFollows) UsersWhoFollowBack() []*User { return friends } +// GetID returns the ID. +func (list *UserFollows) GetID() string { + return list.UserID +} + // UserFollowerCountMap returns a map of user ID keys and their corresping number of followers as the value. func UserFollowerCountMap() map[string]int { followCount := map[string]int{} diff --git a/arn/UserFollowsAPI.go b/arn/UserFollowsAPI.go index a90a2f64..d9de3f93 100644 --- a/arn/UserFollowsAPI.go +++ b/arn/UserFollowsAPI.go @@ -7,6 +7,7 @@ import ( // Force interface implementations var ( + _ Identifiable = (*UserFollows)(nil) _ IDCollection = (*UserFollows)(nil) _ api.Editable = (*UserFollows)(nil) ) diff --git a/arn/UserNotifications.go b/arn/UserNotifications.go index 1d321d9b..d8157eec 100644 --- a/arn/UserNotifications.go +++ b/arn/UserNotifications.go @@ -83,6 +83,11 @@ func (list *UserNotifications) Notifications() []*Notification { return notifications } +// GetID returns the ID. +func (list *UserNotifications) GetID() string { + return list.UserID +} + // GetUserNotifications ... func GetUserNotifications(id UserID) (*UserNotifications, error) { obj, err := DB.Get("UserNotifications", id) diff --git a/arn/UserNotificationsAPI.go b/arn/UserNotificationsAPI.go index 21aea41e..86065107 100644 --- a/arn/UserNotificationsAPI.go +++ b/arn/UserNotificationsAPI.go @@ -2,6 +2,7 @@ package arn // Force interface implementations var ( + _ Identifiable = (*UserNotifications)(nil) _ IDCollection = (*UserNotifications)(nil) )