Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
1c4829f7
Unverified
Commit
1c4829f7
authored
Jul 04, 2020
by
Regev Brody
Committed by
GitHub
Jul 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: tags filtered by access (#2100)
parent
41327dd1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
9 deletions
+34
-9
page.js
server/graph/resolvers/page.js
+34
-9
No files found.
server/graph/resolvers/page.js
View file @
1c4829f7
...
...
@@ -171,26 +171,51 @@ module.exports = {
* FETCH TAGS
*/
async
tags
(
obj
,
args
,
context
,
info
)
{
return
WIKI
.
models
.
tags
.
query
().
orderBy
(
'tag'
,
'asc'
)
const
pages
=
await
WIKI
.
models
.
pages
.
query
().
column
([
'path'
,
{
locale
:
'localeCode'
},
])
.
withGraphJoined
(
'tags'
)
const
allTags
=
_
.
filter
(
pages
,
r
=>
{
return
WIKI
.
auth
.
checkAccess
(
context
.
req
.
user
,
[
'read:pages'
],
{
path
:
r
.
path
,
locale
:
r
.
locale
})
})
.
flatMap
(
r
=>
r
.
tags
)
return
_
.
orderBy
(
_
.
uniqBy
(
allTags
,
'id'
),
[
'tag'
],
[
'asc'
])
},
/**
* SEARCH TAGS
*/
async
searchTags
(
obj
,
args
,
context
,
info
)
{
const
query
=
_
.
trim
(
args
.
query
)
const
results
=
await
WIKI
.
models
.
tags
.
query
()
.
column
(
'tag'
)
.
where
(
builder
=>
{
builder
.
andWhere
(
builderSub
=>
{
const
pages
=
await
WIKI
.
models
.
pages
.
query
().
column
([
'path'
,
{
locale
:
'localeCode'
},
])
.
withGraphJoined
(
'tags'
)
.
modifyGraph
(
'tags'
,
builder
=>
{
builder
.
select
(
'tag'
)
})
.
modify
(
queryBuilder
=>
{
queryBuilder
.
andWhere
(
builderSub
=>
{
if
(
WIKI
.
config
.
db
.
type
===
'postgres'
)
{
builderSub
.
where
(
'tag'
,
'ILIKE'
,
`%
${
query
}
%`
)
builderSub
.
where
(
'tag
s.tag
'
,
'ILIKE'
,
`%
${
query
}
%`
)
}
else
{
builderSub
.
where
(
'tag'
,
'LIKE'
,
`%
${
query
}
%`
)
builderSub
.
where
(
'tag
s.tag
'
,
'LIKE'
,
`%
${
query
}
%`
)
}
})
})
.
limit
(
5
)
return
results
.
map
(
r
=>
r
.
tag
)
const
allTags
=
_
.
filter
(
pages
,
r
=>
{
return
WIKI
.
auth
.
checkAccess
(
context
.
req
.
user
,
[
'read:pages'
],
{
path
:
r
.
path
,
locale
:
r
.
locale
})
})
.
flatMap
(
r
=>
r
.
tags
)
.
map
(
t
=>
t
.
tag
)
return
_
.
uniq
(
allTags
).
slice
(
0
,
5
)
},
/**
* FETCH PAGE TREE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment