diff --git a/common/relations.go b/common/relations.go
index 68965fa2..631969d0 100644
--- a/common/relations.go
+++ b/common/relations.go
@@ -7,20 +7,23 @@ import (
)
type BlockStore interface {
- IsBlockedBy(blocker int, blockee int) (bool, error)
+ IsBlockedBy(blocker, blockee int) (bool, error)
+ Add(blocker, blockee int) error
}
type DefaultBlockStore struct {
isBlocked *sql.Stmt
+ add *sql.Stmt
}
func NewDefaultBlockStore(acc *qgen.Accumulator) (*DefaultBlockStore, error) {
return &DefaultBlockStore{
isBlocked: acc.Select("users_blocks").Cols("blocker").Where("blocker = ? AND blockedUser = ?").Prepare(),
+ add: acc.Insert("users_blocks").Columns("blocker,blockedUser").Fields("?,?").Prepare(),
}, acc.FirstError()
}
-func (s *DefaultBlockStore) IsBlockedBy(blocker int, blockee int) (bool, error) {
+func (s *DefaultBlockStore) IsBlockedBy(blocker, blockee int) (bool, error) {
err := s.isBlocked.QueryRow(blocker, blockee).Scan(&blocker)
if err != nil && err != ErrNoRows {
return false, err
@@ -28,12 +31,47 @@ func (s *DefaultBlockStore) IsBlockedBy(blocker int, blockee int) (bool, error)
return err != ErrNoRows, nil
}
+func (s *DefaultBlockStore) Add(blocker, blockee int) error {
+ return nil
+}
+
+type FriendInvite struct {
+ Requester int
+ Target int
+}
+
type FriendStore interface {
+ AddInvite(requester, target int) error
+ Confirm(requester, target int) error
+ GetOwSentInvites(uid int) ([]FriendInvite, error)
+ GetOwnRecvInvites(uid int) ([]FriendInvite, error)
}
type DefaultFriendStore struct {
+ addInvite *sql.Stmt
+ confirm *sql.Stmt
+ getOwnSentInvites *sql.Stmt
+ getOwnRecvInvites *sql.Stmt
}
func NewDefaultFriendStore(acc *qgen.Accumulator) (*DefaultFriendStore, error) {
- return &DefaultFriendStore{}, acc.FirstError()
+ return &DefaultFriendStore{
+ addInvite: acc.Insert("users_friends_invites").Columns("requester, target").Fields("?,?").Prepare(),
+ confirm: acc.Insert("users_friends").Columns("uid,uid2").Fields("?,?").Prepare(),
+ getOwnSentInvites: acc.Select("users_friends_invites").Cols("requester, target").Where("requester = ?").Prepare(),
+ getOwnRecvInvites: acc.Select("users_friends_invites").Cols("requester, target").Where("target = ?").Prepare(),
+ }, acc.FirstError()
+}
+
+func (s *DefaultFriendStore) AddInvite(requester, target int) error {
+ return nil
+}
+func (s *DefaultFriendStore) Confirm(requester, target int) error {
+ return nil
+}
+func (s *DefaultFriendStore) GetOwnSentInvites(uid int) ([]FriendInvite, error) {
+ return nil, nil
+}
+func (s *DefaultFriendStore) GetOwnRecvInvites(uid int) ([]FriendInvite, error) {
+ return nil, nil
}
diff --git a/parser_test.go b/parser_test.go
index 1f7194d1..747bc38e 100644
--- a/parser_test.go
+++ b/parser_test.go
@@ -209,9 +209,9 @@ func TestParser(t *testing.T) {
s = "https:" + s
fs = "https://" + c.Site.URL
}
- l.Add("//"+u, ""+c.Site.URL+"")
- l.Add("//"+u+"\n", ""+c.Site.URL+"
")
- l.Add("//"+u+"\n//"+u, ""+c.Site.URL+"
"+c.Site.URL+"")
+ l.Add("//"+u, ""+c.Site.URL+"")
+ l.Add("//"+u+"\n", ""+c.Site.URL+"
")
+ l.Add("//"+u+"\n//"+u, ""+c.Site.URL+"
"+c.Site.URL+"")
l.Add("http://"+u, ""+c.Site.URL+"")
l.Add("https://"+u, ""+c.Site.URL+"")
}