mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-28 22:55:39 -04:00
api, frontend: add moderator tag to mods in comments
This commit is contained in:
@ -119,25 +119,24 @@ func commentListHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
commenterHex := "anonymous"
|
||||
isModerator := false
|
||||
if *x.CommenterToken != "anonymous" {
|
||||
c, err := commenterGetByCommenterToken(*x.CommenterToken)
|
||||
if err != nil {
|
||||
if err == errorNoSuchToken {
|
||||
commenterHex = "anonymous"
|
||||
} else {
|
||||
bodyMarshal(w, response{"success": false, "message": err.Error()})
|
||||
return
|
||||
}
|
||||
c, err := commenterGetByCommenterToken(*x.CommenterToken)
|
||||
if err != nil {
|
||||
if err == errorNoSuchToken {
|
||||
commenterHex = "anonymous"
|
||||
} else {
|
||||
commenterHex = c.CommenterHex
|
||||
bodyMarshal(w, response{"success": false, "message": err.Error()})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
commenterHex = c.CommenterHex
|
||||
}
|
||||
|
||||
for _, mod := range d.Moderators {
|
||||
if mod.Email == c.Email {
|
||||
isModerator = true
|
||||
break
|
||||
}
|
||||
isModerator := false
|
||||
modList := map[string]bool{}
|
||||
for _, mod := range d.Moderators {
|
||||
modList[mod.Email] = true
|
||||
if mod.Email == c.Email {
|
||||
isModerator = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,11 +148,20 @@ func commentListHandler(w http.ResponseWriter, r *http.Request) {
|
||||
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{
|
||||
"success": true,
|
||||
"domain": domain,
|
||||
"comments": comments,
|
||||
"commenters": commenters,
|
||||
"commenters": _commenters,
|
||||
"requireModeration": d.RequireModeration,
|
||||
"requireIdentification": d.RequireIdentification,
|
||||
"isFrozen": d.State == "frozen",
|
||||
|
@ -12,4 +12,5 @@ type commenter struct {
|
||||
Photo string `json:"photo"`
|
||||
Provider string `json:"provider,omitempty"`
|
||||
JoinDate time.Time `json:"joinDate,omitempty"`
|
||||
IsModerator bool `json:"isModerator"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user