summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Minko <vitaly.minko@gmail.com>2019-06-11 13:57:14 +0300
committerVitaly Minko <vitaly.minko@gmail.com>2019-06-11 13:57:14 +0300
commit2e03798d4c59acd9275d8363bce45db4e45cc6d6 (patch)
tree5451de82424df479c786e545871b8edb3f7ba729
parenteee321e1e760129e23b7a5a7a5b7db6e09033770 (diff)
Fixed several bugs in the moderator management handlers.
-rw-r--r--cmd/dscuss-cli/main.go8
-rw-r--r--cmd/dscuss-web/controller/board_handlers.go3
-rw-r--r--cmd/dscuss-web/controller/controller.go2
-rw-r--r--cmd/dscuss-web/controller/reply_handlers.go9
-rw-r--r--cmd/dscuss-web/controller/thread_handlers.go3
-rw-r--r--cmd/dscuss-web/main.go2
-rw-r--r--cmd/dscuss-web/view/profile.go2
-rw-r--r--docs/illustrations/class_dia.pngbin621063 -> 621083 bytes
-rw-r--r--docs/illustrations/sources/class_dia.dia2
-rw-r--r--dscuss.go2
-rwxr-xr-xtestbed/managing_moderators.exp2
-rwxr-xr-xtestbed/remove_message_propagation.exp4
-rwxr-xr-xtestbed/syncing_operations.exp4
13 files changed, 21 insertions, 22 deletions
diff --git a/cmd/dscuss-cli/main.go b/cmd/dscuss-cli/main.go
index 3f43203..8c14419 100644
--- a/cmd/dscuss-cli/main.go
+++ b/cmd/dscuss-cli/main.go
@@ -114,9 +114,9 @@ var commandList = []*ishell.Cmd{
Func: doListSubscriptions,
},
{
- Name: "mkmdr",
+ Name: "addmdr",
Help: "<id>, make user <id> a moderator",
- Func: doMakeModerator,
+ Func: doAddModerator,
},
{
Name: "rmmdr",
@@ -607,7 +607,7 @@ func doListSubscriptions(c *ishell.Context) {
c.Print(subs.String())
}
-func doMakeModerator(c *ishell.Context) {
+func doAddModerator(c *ishell.Context) {
if loginHandle == nil {
c.Println("You are not logged in.")
return
@@ -623,7 +623,7 @@ func doMakeModerator(c *ishell.Context) {
c.Println(idStr + " is not a valid entity ID.")
return
}
- err = loginHandle.MakeModerator(&id)
+ err = loginHandle.AddModerator(&id)
if err != nil {
c.Println("Error making new moderator: " + err.Error() + ".")
}
diff --git a/cmd/dscuss-web/controller/board_handlers.go b/cmd/dscuss-web/controller/board_handlers.go
index 5046418..8402bc7 100644
--- a/cmd/dscuss-web/controller/board_handlers.go
+++ b/cmd/dscuss-web/controller/board_handlers.go
@@ -22,7 +22,6 @@ import (
"vminko.org/dscuss"
"vminko.org/dscuss/cmd/dscuss-web/view"
"vminko.org/dscuss/entity"
- "vminko.org/dscuss/log"
"vminko.org/dscuss/subs"
)
@@ -56,7 +55,7 @@ func boardHandler(w http.ResponseWriter, r *http.Request, l *dscuss.LoginHandle,
messages, err = l.ListBoard(0, boardSize)
}
if err != nil {
- log.Fatal("Can't list board: " + err.Error() + ".")
+ panic("Can't list board: " + err.Error() + ".")
}
var threads []RootMessage
diff --git a/cmd/dscuss-web/controller/controller.go b/cmd/dscuss-web/controller/controller.go
index 6dd1674..8413539 100644
--- a/cmd/dscuss-web/controller/controller.go
+++ b/cmd/dscuss-web/controller/controller.go
@@ -37,7 +37,7 @@ func NotFoundHandler(w http.ResponseWriter, r *http.Request) {
}
func BadRequestHandler(w http.ResponseWriter, r *http.Request, msg string) {
- http.Error(w, "Your browser sent a request that this server could not understand. "+msg,
+ http.Error(w, "Your browser sent a request that this server could not perform. "+msg,
http.StatusBadRequest)
}
diff --git a/cmd/dscuss-web/controller/reply_handlers.go b/cmd/dscuss-web/controller/reply_handlers.go
index 2958ffd..361da60 100644
--- a/cmd/dscuss-web/controller/reply_handlers.go
+++ b/cmd/dscuss-web/controller/reply_handlers.go
@@ -23,7 +23,6 @@ import (
"vminko.org/dscuss/cmd/dscuss-web/view"
"vminko.org/dscuss/entity"
"vminko.org/dscuss/errors"
- "vminko.org/dscuss/log"
)
func replyHandler(w http.ResponseWriter, r *http.Request, l *dscuss.LoginHandle, s *Session) {
@@ -60,15 +59,15 @@ func replyHandler(w http.ResponseWriter, r *http.Request, l *dscuss.LoginHandle,
if err == errors.NoSuchEntity {
NotFoundHandler(w, r)
} else if err != nil {
- log.Fatalf("Got an error while fetching msg %s from DB: %v",
- pid.Shorten(), err)
+ panic("Got an error while fetching msg " + pid.Shorten() +
+ " from DB: " + err.Error())
}
pm.Assign(m, l)
root, err := l.GetRootMessage(m)
if err != nil {
- log.Fatalf("Got an error while fetching root for msg %s from DB: %v",
- pid.Shorten(), err)
+ panic("Got an error while fetching root for msg " + pid.Shorten() +
+ " from DB:" + err.Error())
}
rm.Assign(root, l)
diff --git a/cmd/dscuss-web/controller/thread_handlers.go b/cmd/dscuss-web/controller/thread_handlers.go
index 2b6c3f2..882e22b 100644
--- a/cmd/dscuss-web/controller/thread_handlers.go
+++ b/cmd/dscuss-web/controller/thread_handlers.go
@@ -21,7 +21,6 @@ import (
"vminko.org/dscuss"
"vminko.org/dscuss/cmd/dscuss-web/view"
"vminko.org/dscuss/entity"
- "vminko.org/dscuss/log"
"vminko.org/dscuss/thread"
)
@@ -59,7 +58,7 @@ func threadHandler(w http.ResponseWriter, r *http.Request, l *dscuss.LoginHandle
}
node, err := l.ListThread(&tid)
if err != nil {
- log.Fatal("Can't list thread: " + err.Error() + ".")
+ panic("Can't list thread: " + err.Error() + ".")
return
}
var t Thread
diff --git a/cmd/dscuss-web/main.go b/cmd/dscuss-web/main.go
index a1aa71f..a14cf86 100644
--- a/cmd/dscuss-web/main.go
+++ b/cmd/dscuss-web/main.go
@@ -132,6 +132,8 @@ func main() {
http.HandleFunc("/reply", controller.MakeReplyHandler(loginHandle))
http.HandleFunc("/start", controller.MakeStartHandler(loginHandle))
http.HandleFunc("/profile", controller.MakeProfileHandler(loginHandle))
+ http.HandleFunc("/addmdr", controller.MakeAddModeratorHandler(loginHandle))
+ http.HandleFunc("/rmmdr", controller.MakeRemoveModeratorHandler(loginHandle))
http.HandleFunc("/", controller.MakeRootHandler(loginHandle))
log.Debugf("Starting HTTP server on port %d\n", webPort)
diff --git a/cmd/dscuss-web/view/profile.go b/cmd/dscuss-web/view/profile.go
index 1df2c3f..6854fa1 100644
--- a/cmd/dscuss-web/view/profile.go
+++ b/cmd/dscuss-web/view/profile.go
@@ -54,7 +54,7 @@ const profileHTML = `
</form>
<hr class="sep">
<span class="subtitle">Moderators</span>
-<form action="/mkmdr" method="POST" enctype="multipart/form-data">
+<form action="/addmdr" method="POST" enctype="multipart/form-data">
<input type="hidden" name="csrf" value="{{ .Common.CSRF }}">
<table>
<tr>
diff --git a/docs/illustrations/class_dia.png b/docs/illustrations/class_dia.png
index 6b480f3..d744030 100644
--- a/docs/illustrations/class_dia.png
+++ b/docs/illustrations/class_dia.png
Binary files differ
diff --git a/docs/illustrations/sources/class_dia.dia b/docs/illustrations/sources/class_dia.dia
index b85b211..beb6878 100644
--- a/docs/illustrations/sources/class_dia.dia
+++ b/docs/illustrations/sources/class_dia.dia
@@ -15733,7 +15733,7 @@ User#</dia:string>
</dia:composite>
<dia:composite type="umloperation">
<dia:attribute name="name">
- <dia:string>#MakeModerator#</dia:string>
+ <dia:string>#AddModerator#</dia:string>
</dia:attribute>
<dia:attribute name="stereotype">
<dia:string>##</dia:string>
diff --git a/dscuss.go b/dscuss.go
index d8adf8f..09b7a83 100644
--- a/dscuss.go
+++ b/dscuss.go
@@ -319,7 +319,7 @@ func (lh *LoginHandle) ListSubscriptions() subs.Subscriptions {
return lh.owner.Profile.GetSubscriptions()
}
-func (lh *LoginHandle) MakeModerator(id *entity.ID) error {
+func (lh *LoginHandle) AddModerator(id *entity.ID) error {
has, err := lh.owner.Storage.HasUser(id)
if err != nil {
log.Errorf("Failed to check if storage contains %s: %v", id.Shorten(), err)
diff --git a/testbed/managing_moderators.exp b/testbed/managing_moderators.exp
index 2cba544..c57fcf1 100755
--- a/testbed/managing_moderators.exp
+++ b/testbed/managing_moderators.exp
@@ -92,7 +92,7 @@ expect {
}
say "Making Eve a moderator"
-send "mkmdr jNhpT2bYG/YQR3Dejo69mREhcXVWt0jnx1fE8r1ql7E=\r"
+send "addmdr jNhpT2bYG/YQR3Dejo69mREhcXVWt0jnx1fE8r1ql7E=\r"
expect "> "
say "Checking updates Adam's list of moderators"
diff --git a/testbed/remove_message_propagation.exp b/testbed/remove_message_propagation.exp
index f5a4b48..792dd69 100755
--- a/testbed/remove_message_propagation.exp
+++ b/testbed/remove_message_propagation.exp
@@ -37,7 +37,7 @@ send "login eve\r"
expect "> "
send "whoami\r"
expect -re "eve (.*)\r\n"
-send "mkmdr 8vBHkCKnH/QiLeN8cXduVLG8BGfAMkiFtwKELEH3Gyc=\r"
+send "addmdr 8vBHkCKnH/QiLeN8cXduVLG8BGfAMkiFtwKELEH3Gyc=\r"
expect "> "
say "Starting Cain's peer"
@@ -48,7 +48,7 @@ send "login cain\r"
expect "> "
send "whoami\r"
expect -re "cain (.*)\r\n"
-send "mkmdr 8vBHkCKnH/QiLeN8cXduVLG8BGfAMkiFtwKELEH3Gyc=\r"
+send "addmdr 8vBHkCKnH/QiLeN8cXduVLG8BGfAMkiFtwKELEH3Gyc=\r"
expect "> "
say "Giving peers some time to perform handshaking"
diff --git a/testbed/syncing_operations.exp b/testbed/syncing_operations.exp
index 76cf559..90a578a 100755
--- a/testbed/syncing_operations.exp
+++ b/testbed/syncing_operations.exp
@@ -44,7 +44,7 @@ send "login eve\r"
expect "> "
send "whoami\r"
expect -re "eve (.*)\r\n"
-send "mkmdr 8vBHkCKnH/QiLeN8cXduVLG8BGfAMkiFtwKELEH3Gyc=\r"
+send "addmdr 8vBHkCKnH/QiLeN8cXduVLG8BGfAMkiFtwKELEH3Gyc=\r"
expect "> "
say "Starting Cain's peer"
@@ -55,7 +55,7 @@ send "login cain\r"
expect "> "
send "whoami\r"
expect -re "cain (.*)\r\n"
-send "mkmdr 8vBHkCKnH/QiLeN8cXduVLG8BGfAMkiFtwKELEH3Gyc=\r"
+send "addmdr 8vBHkCKnH/QiLeN8cXduVLG8BGfAMkiFtwKELEH3Gyc=\r"
expect "> "
say "Giving peers some time to perform handshaking and syncing"