mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FEATURE: better email in support
FEATURE: new incoming_email model FEATURE: infinite scrolling in emails admin FEATURE: new 'emails:import' rake task
This commit is contained in:
@ -10,6 +10,6 @@ class DropGroupManagers < ActiveRecord::Migration
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrriversableMigration
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
|
24
db/migrate/20160113160742_create_incoming_emails.rb
Normal file
24
db/migrate/20160113160742_create_incoming_emails.rb
Normal file
@ -0,0 +1,24 @@
|
||||
class CreateIncomingEmails < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :incoming_emails do |t|
|
||||
t.integer :user_id
|
||||
t.integer :topic_id
|
||||
t.integer :post_id
|
||||
|
||||
t.text :raw
|
||||
t.text :error
|
||||
|
||||
t.text :message_id
|
||||
t.text :from_address
|
||||
t.text :to_addresses
|
||||
t.text :cc_addresses
|
||||
t.text :subject
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :incoming_emails, :created_at
|
||||
add_index :incoming_emails, :message_id
|
||||
add_index :incoming_emails, :error
|
||||
end
|
||||
end
|
28
db/migrate/20160118233631_backfill_incoming_emails.rb
Normal file
28
db/migrate/20160118233631_backfill_incoming_emails.rb
Normal file
@ -0,0 +1,28 @@
|
||||
class BackfillIncomingEmails < ActiveRecord::Migration
|
||||
def up
|
||||
execute <<-SQL
|
||||
INSERT INTO incoming_emails (post_id, created_at, updated_at, user_id, topic_id, message_id, from_address, to_addresses, subject)
|
||||
SELECT posts.id
|
||||
, posts.created_at
|
||||
, posts.created_at
|
||||
, posts.user_id
|
||||
, posts.topic_id
|
||||
, array_to_string(regexp_matches(posts.raw_email, '^\s*Message-Id: .*<([^>]+)>', 'im'), '')
|
||||
, users.email
|
||||
, array_to_string(regexp_matches(array_to_string(regexp_matches(posts.raw_email, '^to:.+$', 'im'), ''), '[^<\s"''(]+@[^>\s"'')]+'), '')
|
||||
, topics.title
|
||||
FROM posts
|
||||
JOIN topics ON posts.topic_id = topics.id
|
||||
JOIN users ON posts.user_id = users.id
|
||||
WHERE posts.user_id IS NOT NULL
|
||||
AND posts.topic_id IS NOT NULL
|
||||
AND posts.via_email = 't'
|
||||
AND posts.raw_email ~* 'Message-Id'
|
||||
ORDER BY posts.id;
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user