When a Community member requests a Subject Access Request (SAR) we would provide a copy of their User Notes left by mods etc.
Can these be exported into a csv (or similar)?
When a Community member requests a Subject Access Request (SAR) we would provide a copy of their User Notes left by mods etc.
Can these be exported into a csv (or similar)?
I think you can do this via the Rails console. Run:
./launcher enter app
rails c
to enter the console. Then:
DiscourseUserNotes.notes_for(user_id)
Replace user_id with the user’s id. This returns a JSON of the user notes.
You can export the results of a data explorer query as a CSV file (or JSON).
I adjusted the query shared in Analyzing Moderation and Flagging Activity Reports to return all notes tied to a specific user instead of a time span. I also removed most columns from the original because I don’t think the author of the note should be included in your case.
-- [params]
-- user_id :user_id
WITH user_notes AS (
SELECT
REPLACE(key, 'notes:', '')::int AS user_id,
notes.value->>'raw' AS user_note
FROM plugin_store_rows,
LATERAL json_array_elements(value::json) notes
WHERE plugin_name = 'user_notes'
ORDER BY 2 DESC
)
SELECT un.user_note
FROM user_notes un
JOIN users u ON u.id = un.user_id
WHERE un.user_id = :user_id