Inserting/updating config groups from the CLI

Hi! It would be great if the pleroma.config mix task could include something like “create” or “replace”.
Use case: I want to populate the mrf_simple policy with a bunch of domains that I pull from a blocklist. At the moment I can only insert them one by one using adminFE. If the blocklist changes, I have to do a manual diff to keep my list in sync.
“migrate_to_db” could work, but it’s going to call truncatedb() first and remove any existing config in the db.
Maybe something that only removes a specific group and re-creates it from a config file?

1 Like

What you could do instead:

  • use migrate_from_db to export config
  • edit exported config to include the blocklist
  • paste edited exported config to the end of your config.exs
  • restart akkoma
  • import changed settings with migrate_to_db
  • remove exported config stuff from your config.exs
  • restart akkoma

edit: fix lost settings.
note: make sure to have a backup/snapshot and don’t delete your exported settings too fast from your disk :wink:

1 Like

Sure, that works too, but automating it would be a lot more effort :slight_smile:
I’ll use this approach for now, but a new task to only replace one config group would be much appreciated!

i may have mixed up something, i just killed my config :smiley:

Oh shit, I’m sorry :grimacing:

1 Like

I stored the exported config instead of deleting it this time and i made a snapshot of the server before this, so i was able to fix it. And i now know, what works. I’ll update my first post.

It’s a bit error-prone but it works. I’ll do it like this for now, I might try to write some Elixir code and send a patch at some point :slight_smile:

1 Like

not directly related to the point at hand but i would advise against pulling blocks from an online list
in fact, the inability to just import a csv is a good thing, as it encourages you to do your due diligence as an admin and investigate the block reasons instead of taking them for granted

1 Like

I agree, but in this case I’ve been through the list already and I know what I’m blocking, I just need a better interface than AdminFE to import it.
The hack published by @django works so far, and I won’t update that list more than once per week.
P.S. This is a one-person instance, I’m basically moderating myself at this point :smiley:
I prefer to over-block instead of running into edgy/free-speech/generally unpleasant people.

3 Likes

whilst i see the benefit, it may be a little bit of a pain - we’d have to serialise values in a way elixir understands

i’ll see how much of a trouble that is, maybe it won’t be who knows :googly:

1 Like

implemented via Add dump_to_file and load_from_file tasks · d1bf8aa9ed - akkoma - Akkoma Development

see Transfering the config to/from the database - Akkoma Documentation

merged into develop, will be included in 2023.02

5 Likes