Unable to edit the post privilages error
venkAT
Posts
-
Unable to edit the post privilages issues -
How to setup admin user in config.json in nodebbFor build promotions we have to auto create the admin account from Jenkins or some environment variable
can we use config.json to setup admin accountplease guide us, How can we use the below command.
./nodebb setup [options] [config]We refer the below link but not successed:
https://community.nodebb.org/topic/14068/setting-up-nodebb-for-ci-cd-pipeline -
Tags are not updated while editing the post (/api/v2/posts/:pid)My local Nodebb Version :
v1.16.2
I am trying to edit my own post and I want to update the
content
,title
andtags
Here is my payload
curl --location --request PUT 'http://localhost:4567/api/v2/posts/17' \ --header 'Authorization: Bearer 0257ecdd-ffd7-4a79-a2c4-2244aa490c2d' \ --header 'Content-Type: application/json' \ --header 'Cookie: express.sid=s%3AbIhfigykYJ3MKanc6ShQ2gGxoZ6xccjE.s02leB%2BLFWGPnXG1IBQQdaTb8gD%2BDobwa05UEYja1Ws' \ --data-raw '{ "pid": 17, "content": "Edit my own post alsong with tags", "title": "Edit post", "tags": ["edit", "update", "tagCheck"] }'
And I got response back
{ "code": "ok", "payload": {} }
But the tags are not updated, check the screenshot
These are my findings
STEP: 1 - Nodebb-WriteAPI
in write api plugin for the api/api/v2/posts/:pid
verify From line number 19 to 33
https://github.com/NodeBB/nodebb-plugin-write-api/blob/master/routes/v2/posts.js#L19Here the tags are added into
options
object - #Line: 29in write api the final object looks like this
{ uid: 18, pid: '17', content: 'Edit my own post alsong with tags', options: { tags: [ 'edit', 'update', 'tagCheck' ] }, title: 'Edit post' }
STEP:2 - NodeBB (POSTS section)
As par the above git link #lineNo: 31 we are calling parent funtionposts.edit
so that will come to NodeBBsrc/posts/edit.js
file.
Verify Here:
https://github.com/NodeBB/NodeBB/blob/master/src/posts/edit.js#L126You are access the tags from data object
data.tags
but Actually tags present indata.options.tags
Referencs Data object in Nodebb
{ uid: 18, pid: '17', content: 'Edit my own post alsong with tags', options: { tags: [ 'edit', 'update', 'tagCheck' ] }, title: 'Edit post' }
And finally The updated data object looks like
{ tid: 17, cid: 2, uid: 18, title: 'Edit post', oldTitle: 'Edit post', slug: '17/edit-post', isMainPost: true, renamed: false, tags: [] }
Because off the tags access from wrong place, causing issue for updating the tags while editing the post
my local practice
- in my local I changed the tags accessing in Nodebb(
/src/posts/edit.js#LineNo: 126
) fromdata.tags = data.tags || [];
todata.tags = data.options.tags || [];
After that the tags are updating for that post
CC: @vinu
- in my local I changed the tags accessing in Nodebb(