A user wants to strip the mailing list prefix from email subjects when creating topics in Discourse. paradeiser asks for help, and pfaffman initially suggests modifying the importer.rb file, but later realizes the issue is not about importing mbox files. gerhard clarifies that the correct approach is using a plugin or a topic_created webhook to modify the topic title via the API. paradeiser confirms the problem is with incoming emails from a mailing list, not an import, and seeks confirmation on the correct method.
I’m polling emails from a mailinglist to discourse, the subjects of the mails generate new topics. That’s working fine.
Now I need to remove the first part of the subject, as it’s just the name of the mailinglist
“[mailinglist] actual topic” and I want to extract just the “actual topic”
I couldn’t find the right solution online so far - anyone?
Thank you,
marko
I changed the mbox/importer.rb using the corrected RegEx and also tried a static replace string without any change of the incoming topics.
I’ll try to clarify:
I subscribed the email-adress of the related dicourse category (custom address for incoming e-mails; √ category mirrors mailing-list) to the existing mailing-list
discourse receives this mails and creates according topics
as the mailing-list adds a prefix to the email-subject, I want to remove it before discourse creates the topic
My questions now
is ./script/import_scripts/mbox/importer.rb the correct importer?
is the .gsub("remove this prefix ","") syntaxt right?
I tried mapped[:title] = row['subject'].strip[0...255].gsub(/^\[(.*?)\]\s/,"")
The importer has nothing to do with this. You will need a plugin (shouldn’t be more than a couple lines of code) or a consumer for the topic_created webhook which could use the API to modify the topic title.