start laying down the skeletons for blocks and friends

This commit is contained in:
Azareal 2019-10-13 18:50:55 +10:00
parent 3472dae669
commit 5404b6fdbe
3 changed files with 57 additions and 9 deletions

28
common/relations.go Normal file
View File

@ -0,0 +1,28 @@
package common
import qgen "github.com/Azareal/Gosora/query_gen"
type BlockStore interface {
IsBlockedBy(blocker int, blockee int) (bool, error)
}
type DefaultBlockStore struct {
}
func NewDefaultBlockStore(acc *qgen.Accumulator) (*DefaultBlockStore, error) {
return &DefaultBlockStore{}, acc.FirstError()
}
func (s *DefaultBlockStore) IsBlockedBy(blocker int, blockee int) (bool, error) {
return false, nil
}
type FriendStore interface {
}
type DefaultFriendStore struct {
}
func NewDefaultFriendStore(acc *qgen.Accumulator) (*DefaultFriendStore, error) {
return &DefaultFriendStore{}, acc.FirstError()
}

View File

@ -91,6 +91,9 @@ func userRoutes() *RouteGroup {
Action("routes.ConvosCreateReplySubmit", "/user/convo/create/submit/", "extraData"), Action("routes.ConvosCreateReplySubmit", "/user/convo/create/submit/", "extraData"),
Action("routes.ConvosDeleteReplySubmit", "/user/convo/delete/submit/", "extraData"), Action("routes.ConvosDeleteReplySubmit", "/user/convo/delete/submit/", "extraData"),
Action("routes.ConvosEditReplySubmit", "/user/convo/edit/submit/", "extraData"), Action("routes.ConvosEditReplySubmit", "/user/convo/edit/submit/", "extraData"),
//MView("routes.RelationsBlockCreate","/user/block/create/","extraData")
//Action("routes.RelationsBlockCreateSubmit","/user/block/create/submit/","extraData")
) )
} }

View File

@ -156,12 +156,9 @@ func ConvosCreateSubmit(w http.ResponseWriter, r *http.Request, user c.User) c.R
if err != nil { if err != nil {
return c.LocalError(p.GetErrorPhrase("id_must_be_integer"), w, r, user) return c.LocalError(p.GetErrorPhrase("id_must_be_integer"), w, r, user)
} }
if err := c.Convos.Delete(cid); err != nil {
err = c.Convos.Delete(cid)
if err != nil {
return c.InternalError(err, w, r) return c.InternalError(err, w, r)
} }
http.Redirect(w, r, "/user/convos/", http.StatusSeeOther) http.Redirect(w, r, "/user/convos/", http.StatusSeeOther)
return nil return nil
}*/ }*/
@ -269,7 +266,7 @@ func ConvosEditReplySubmit(w http.ResponseWriter, r *http.Request, user c.User,
if !user.Perms.UseConvos { if !user.Perms.UseConvos {
return c.NoPermissions(w, r, user) return c.NoPermissions(w, r, user)
} }
js := (r.PostFormValue("js") == "1") js := r.PostFormValue("js") == "1"
post := &c.ConversationPost{ID: cpid} post := &c.ConversationPost{ID: cpid}
err = post.Fetch() err = post.Fetch()
@ -309,3 +306,23 @@ func ConvosEditReplySubmit(w http.ResponseWriter, r *http.Request, user c.User,
} }
return nil return nil
} }
func RelationsBlockCreate(w http.ResponseWriter, r *http.Request, user c.User, h *c.Header, spid string) c.RouteError {
accountEditHead("create_block", w, r, &user, h)
pid, err := strconv.Atoi(spid)
if err != nil {
return c.LocalError(p.GetErrorPhrase("id_must_be_integer"), w, r, user)
}
puser, err := c.Users.Get(pid)
if err == sql.ErrNoRows {
return c.LocalError("The user you're trying to block doesn't exist.", w, r, user)
} else if err != nil {
return c.InternalError(err, w, r)
}
pi := c.Account{h, "dashboard", "create_block", puser}
return renderTemplate("account", w, r, h, pi)
}
func RelationsBlockCreateSubmit(w http.ResponseWriter, r *http.Request, user c.User, h *c.Header, spid string) c.RouteError {
return nil
}