api, frontend: add moderator tag to mods in comments
This commit is contained in:
parent
c30da607cb
commit
789a58bd7a
@ -119,25 +119,24 @@ func commentListHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
commenterHex := "anonymous"
|
commenterHex := "anonymous"
|
||||||
isModerator := false
|
c, err := commenterGetByCommenterToken(*x.CommenterToken)
|
||||||
if *x.CommenterToken != "anonymous" {
|
if err != nil {
|
||||||
c, err := commenterGetByCommenterToken(*x.CommenterToken)
|
if err == errorNoSuchToken {
|
||||||
if err != nil {
|
commenterHex = "anonymous"
|
||||||
if err == errorNoSuchToken {
|
|
||||||
commenterHex = "anonymous"
|
|
||||||
} else {
|
|
||||||
bodyMarshal(w, response{"success": false, "message": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
commenterHex = c.CommenterHex
|
bodyMarshal(w, response{"success": false, "message": err.Error()})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
commenterHex = c.CommenterHex
|
||||||
|
}
|
||||||
|
|
||||||
for _, mod := range d.Moderators {
|
isModerator := false
|
||||||
if mod.Email == c.Email {
|
modList := map[string]bool{}
|
||||||
isModerator = true
|
for _, mod := range d.Moderators {
|
||||||
break
|
modList[mod.Email] = true
|
||||||
}
|
if mod.Email == c.Email {
|
||||||
|
isModerator = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,11 +148,20 @@ func commentListHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_commenters := map[string]commenter{}
|
||||||
|
for commenterHex, cr := range commenters {
|
||||||
|
if _, ok := modList[cr.Email]; ok {
|
||||||
|
cr.IsModerator = true
|
||||||
|
}
|
||||||
|
cr.Email = ""
|
||||||
|
_commenters[commenterHex] = cr
|
||||||
|
}
|
||||||
|
|
||||||
bodyMarshal(w, response{
|
bodyMarshal(w, response{
|
||||||
"success": true,
|
"success": true,
|
||||||
"domain": domain,
|
"domain": domain,
|
||||||
"comments": comments,
|
"comments": comments,
|
||||||
"commenters": commenters,
|
"commenters": _commenters,
|
||||||
"requireModeration": d.RequireModeration,
|
"requireModeration": d.RequireModeration,
|
||||||
"requireIdentification": d.RequireIdentification,
|
"requireIdentification": d.RequireIdentification,
|
||||||
"isFrozen": d.State == "frozen",
|
"isFrozen": d.State == "frozen",
|
||||||
|
@ -12,4 +12,5 @@ type commenter struct {
|
|||||||
Photo string `json:"photo"`
|
Photo string `json:"photo"`
|
||||||
Provider string `json:"provider,omitempty"`
|
Provider string `json:"provider,omitempty"`
|
||||||
JoinDate time.Time `json:"joinDate,omitempty"`
|
JoinDate time.Time `json:"joinDate,omitempty"`
|
||||||
|
IsModerator bool `json:"isModerator"`
|
||||||
}
|
}
|
||||||
|
@ -743,6 +743,9 @@
|
|||||||
if (isModerator && comment.state !== "approved") {
|
if (isModerator && comment.state !== "approved") {
|
||||||
classAdd(card, "dark-card");
|
classAdd(card, "dark-card");
|
||||||
}
|
}
|
||||||
|
if (commenter.isModerator) {
|
||||||
|
classAdd(name, "moderator");
|
||||||
|
}
|
||||||
if (comment.state === "flagged") {
|
if (comment.state === "flagged") {
|
||||||
classAdd(name, "flagged");
|
classAdd(name, "flagged");
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,17 @@
|
|||||||
border-radius: 100px;
|
border-radius: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.commento-moderator::after {
|
||||||
|
content: "Moderator";
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 10px;
|
||||||
|
background: $green-7;
|
||||||
|
color: white;
|
||||||
|
margin-left: 8px;
|
||||||
|
padding: 2px 6px 2px 6px;
|
||||||
|
border-radius: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
.commento-subtitle {
|
.commento-subtitle {
|
||||||
display: block;
|
display: block;
|
||||||
color: #999;
|
color: #999;
|
||||||
|
Loading…
Reference in New Issue
Block a user