pull/7910/merge
mod242 1 week ago committed by GitHub
commit 938844e3a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -78,8 +78,8 @@
) )
template(v-slot:icon) template(v-slot:icon)
v-avatar(color='blue-grey') v-avatar(color='blue-grey')
//- v-img(src='http://i.pravatar.cc/64') v-img(v-if='cm.pictureUrl', :src='cm.pictureUrl')
span.white--text.title {{cm.initials}} span.white--text.title(v-else) {{cm.initials}}
v-card.elevation-1 v-card.elevation-1
v-card-text v-card-text
.comments-post-actions(v-if='permissions.manage && !isBusy && commentEditId === 0') .comments-post-actions(v-if='permissions.manage && !isBusy && commentEditId === 0')
@ -182,7 +182,9 @@ export default {
list(locale: $locale, path: $path) { list(locale: $locale, path: $path) {
id id
render render
authorId
authorName authorName
authorPictureUrl
createdAt createdAt
updatedAt updatedAt
} }
@ -201,6 +203,10 @@ export default {
if (nameParts.length > 1) { if (nameParts.length > 1) {
initials += _.last(nameParts).charAt(0) initials += _.last(nameParts).charAt(0)
} }
const pictureUrl = (c.authorPictureUrl === 'internal')
? `/_userav/${c.authorId}`
: c.authorPictureUrl
c.pictureUrl = pictureUrl
c.initials = initials c.initials = initials
return c return c
}) })

@ -47,12 +47,19 @@ module.exports = {
}) })
if (page) { if (page) {
if (WIKI.auth.checkAccess(context.req.user, ['read:comments'], { tags: page.tags, ...args })) { if (WIKI.auth.checkAccess(context.req.user, ['read:comments'], { tags: page.tags, ...args })) {
const comments = await WIKI.models.comments.query().where('pageId', page.id).orderBy('createdAt') const comments = await WIKI.models.comments.query()
.where('pageId', page.id)
.withGraphJoined('author')
.modifyGraph('author', builder => {
builder.select('id', 'pictureUrl')
})
.orderBy('createdAt')
return comments.map(c => ({ return comments.map(c => ({
...c, ...c,
authorName: c.name, authorName: c.name,
authorEmail: c.email, authorEmail: c.email,
authorIP: c.ip authorIP: c.ip,
authorPictureUrl: _.get(c, 'author.pictureUrl', '')
})) }))
} else { } else {
throw new WIKI.Error.CommentViewForbidden() throw new WIKI.Error.CommentViewForbidden()
@ -69,6 +76,7 @@ module.exports = {
if (!cm || !cm.pageId) { if (!cm || !cm.pageId) {
throw new WIKI.Error.CommentNotFound() throw new WIKI.Error.CommentNotFound()
} }
const author = await WIKI.models.users.query().select('pictureUrl').findById(cm.authorId)
const page = await WIKI.models.pages.query().select('localeCode', 'path').findById(cm.pageId) const page = await WIKI.models.pages.query().select('localeCode', 'path').findById(cm.pageId)
.withGraphJoined('tags') .withGraphJoined('tags')
.modifyGraph('tags', builder => { .modifyGraph('tags', builder => {
@ -84,7 +92,8 @@ module.exports = {
...cm, ...cm,
authorName: cm.name, authorName: cm.name,
authorEmail: cm.email, authorEmail: cm.email,
authorIP: cm.ip authorIP: cm.ip,
authorPictureUrl: _.get(author, 'pictureUrl', '')
} }
} else { } else {
throw new WIKI.Error.CommentViewForbidden() throw new WIKI.Error.CommentViewForbidden()

@ -81,6 +81,7 @@ type CommentPost {
render: String! render: String!
authorId: Int! authorId: Int!
authorName: String! authorName: String!
authorPictureUrl: String
authorEmail: String! @auth(requires: ["manage:system"]) authorEmail: String! @auth(requires: ["manage:system"])
authorIP: String! @auth(requires: ["manage:system"]) authorIP: String! @auth(requires: ["manage:system"])
createdAt: Date! createdAt: Date!

Loading…
Cancel
Save