0.2.0 tag, checkpoint release.
Added the Log function. Added the Logf function. Added the Author method to *Topic. Added the action_end_edit_reply hook. Added the action_end_delete_reply hook.
This commit is contained in:
parent
1115c0a4c5
commit
0dd4db4d03
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/Azareal/Gosora/query_gen"
|
"github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
var SoftwareVersion = Version{Major: 0, Minor: 2, Patch: 0, Tag: "dev"}
|
var SoftwareVersion = Version{Major: 0, Minor: 2, Patch: 0, Tag: ""}
|
||||||
|
|
||||||
// nolint I don't want to write comments for each of these o.o
|
// nolint I don't want to write comments for each of these o.o
|
||||||
const Hour int = 60 * 60
|
const Hour int = 60 * 60
|
||||||
|
@ -139,3 +139,11 @@ func DebugLogf(str string, args ...interface{}) {
|
||||||
log.Printf(str, args...)
|
log.Printf(str, args...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Log(args ...interface{}) {
|
||||||
|
log.Print(args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Logf(str string, args ...interface{}) {
|
||||||
|
log.Printf(str, args...)
|
||||||
|
}
|
||||||
|
|
|
@ -85,6 +85,8 @@ var hookTable = &HookTable{
|
||||||
|
|
||||||
"action_end_create_topic": nil,
|
"action_end_create_topic": nil,
|
||||||
"action_end_create_reply": nil,
|
"action_end_create_reply": nil,
|
||||||
|
"action_end_edit_reply": nil,
|
||||||
|
"action_end_delete_reply": nil,
|
||||||
|
|
||||||
"router_pre_route": nil,
|
"router_pre_route": nil,
|
||||||
},
|
},
|
||||||
|
|
|
@ -366,6 +366,11 @@ func (topic *Topic) CreateActionReply(action string, ipaddress string, uid int)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Test this
|
||||||
|
func (topic *Topic) Author() (*User, error) {
|
||||||
|
return Users.Get(topic.CreatedBy)
|
||||||
|
}
|
||||||
|
|
||||||
func (topic *Topic) GetID() int {
|
func (topic *Topic) GetID() int {
|
||||||
return topic.ID
|
return topic.ID
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,6 @@ func CreateReplySubmit(w http.ResponseWriter, r *http.Request, user common.User)
|
||||||
// TODO: Update the stats after edits so that we don't under or over decrement stats during deletes
|
// TODO: Update the stats after edits so that we don't under or over decrement stats during deletes
|
||||||
func ReplyEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, srid string) common.RouteError {
|
func ReplyEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, srid string) common.RouteError {
|
||||||
js := (r.PostFormValue("js") == "1")
|
js := (r.PostFormValue("js") == "1")
|
||||||
|
|
||||||
rid, err := strconv.Atoi(srid)
|
rid, err := strconv.Atoi(srid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.PreErrorJSQ("The provided Reply ID is not a valid number.", w, r, js)
|
return common.PreErrorJSQ("The provided Reply ID is not a valid number.", w, r, js)
|
||||||
|
@ -236,7 +235,7 @@ func ReplyEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, s
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add hooks to make use of headerLite
|
// TODO: Add hooks to make use of headerLite
|
||||||
_, ferr := common.SimpleForumUserCheck(w, r, &user, topic.ParentID)
|
lite, ferr := common.SimpleForumUserCheck(w, r, &user, topic.ParentID)
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
|
@ -262,6 +261,11 @@ func ReplyEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, s
|
||||||
return common.InternalErrorJSQ(err, w, r, js)
|
return common.InternalErrorJSQ(err, w, r, js)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skip, rerr := lite.Hooks.VhookSkippable("action_end_edit_reply", reply.ID)
|
||||||
|
if skip || rerr != nil {
|
||||||
|
return rerr
|
||||||
|
}
|
||||||
|
|
||||||
if !js {
|
if !js {
|
||||||
http.Redirect(w, r, "/topic/"+strconv.Itoa(topic.ID)+"#reply-"+strconv.Itoa(rid), http.StatusSeeOther)
|
http.Redirect(w, r, "/topic/"+strconv.Itoa(topic.ID)+"#reply-"+strconv.Itoa(rid), http.StatusSeeOther)
|
||||||
} else {
|
} else {
|
||||||
|
@ -279,7 +283,6 @@ func ReplyEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, s
|
||||||
// TODO: Disable stat updates in posts handled by plugin_guilds
|
// TODO: Disable stat updates in posts handled by plugin_guilds
|
||||||
func ReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User, srid string) common.RouteError {
|
func ReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User, srid string) common.RouteError {
|
||||||
isJs := (r.PostFormValue("isJs") == "1")
|
isJs := (r.PostFormValue("isJs") == "1")
|
||||||
|
|
||||||
rid, err := strconv.Atoi(srid)
|
rid, err := strconv.Atoi(srid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.PreErrorJSQ("The provided Reply ID is not a valid number.", w, r, isJs)
|
return common.PreErrorJSQ("The provided Reply ID is not a valid number.", w, r, isJs)
|
||||||
|
@ -300,7 +303,7 @@ func ReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add hooks to make use of headerLite
|
// TODO: Add hooks to make use of headerLite
|
||||||
_, ferr := common.SimpleForumUserCheck(w, r, &user, topic.ParentID)
|
lite, ferr := common.SimpleForumUserCheck(w, r, &user, topic.ParentID)
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
|
@ -313,6 +316,11 @@ func ReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User,
|
||||||
return common.InternalErrorJSQ(err, w, r, isJs)
|
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skip, rerr := lite.Hooks.VhookSkippable("action_end_delete_reply", reply.ID)
|
||||||
|
if skip || rerr != nil {
|
||||||
|
return rerr
|
||||||
|
}
|
||||||
|
|
||||||
//log.Printf("Reply #%d was deleted by common.User #%d", rid, user.ID)
|
//log.Printf("Reply #%d was deleted by common.User #%d", rid, user.ID)
|
||||||
if !isJs {
|
if !isJs {
|
||||||
http.Redirect(w, r, "/topic/"+strconv.Itoa(reply.ParentID), http.StatusSeeOther)
|
http.Redirect(w, r, "/topic/"+strconv.Itoa(reply.ParentID), http.StatusSeeOther)
|
||||||
|
@ -320,6 +328,7 @@ func ReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User,
|
||||||
w.Write(successJSONBytes)
|
w.Write(successJSONBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ? - What happens if an error fires after a redirect...?
|
||||||
replyCreator, err := common.Users.Get(reply.CreatedBy)
|
replyCreator, err := common.Users.Get(reply.CreatedBy)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
wcount := common.WordCount(reply.Content)
|
wcount := common.WordCount(reply.Content)
|
||||||
|
|
Loading…
Reference in New Issue