Where are staff notices stored in the database?

Does anyone know how to query staff notes notices from the database? I’ve been looking around in the code but haven’t been able to find where they are stored.

My main goal is to find a specific staff notice that was written in the past week, so I’m looking for a way to skim through the recent custom ones.

Edit: I was having trouble, because I was looking for “staff notes”. I’ve just found a custom_field that might be what I’m looking for, but I’m not sure how to list all the staff notices with custom text.

pry(main)> p.custom_fields
=> {"notice_type"=>"new_user"}

PlugintStoreRow.where(plugin_name: "user_notes") is probably what you’re looking for

2 Likes

Thanks, I’m looking for “staff notices” (core feature), which I think is different from “user notes” (separate plugin). I might be confused though. :slight_smile:

The item named “Add Staff Notice”:

image

2 Likes

It should be in the custom fields like you’ve mentioned

https://github.com/discourse/discourse/blob/e90aac11cbd133263f1bd9c222ae87892fb3f8e4/app/controllers/posts_controller.rb#L484-L498

4 Likes

Thanks. In case anyone else is looking for a quick way to skim the data, this works in the Rails console:

results = Post.all.reject { |p| p.custom_fields['notice_type'].nil? }

results.each do |r|
  puts r.custom_fields
end

Sample output:

{"notice_type"=>"returning_user", "notice_args"=>"2018-08-04T07:43:52Z"}
{"notice_type"=>"new_user"}
{"notice_type"=>"new_user"}
{"notice_type"=>"new_user"}
{"notice_type"=>"returning_user", "notice_args"=>"2016-10-11T09:32:30Z"}
{"notice_type"=>"returning_user", "notice_args"=>"2014-04-02T16:16:04Z"}
{"notice_type"=>"new_user"}
{"notice_type"=>"new_user"}

I don’t see any custom text there, so I guess the staff notice I was looking for isn’t live.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.