mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Revert "FIX: Partial reply key search in email sent logs."
This reverts commit e9b2018bc8.
This commit is contained in:
@@ -30,10 +30,16 @@ class Admin::EmailController < Admin::AdminController
|
|||||||
|
|
||||||
email_logs = filter_logs(email_logs, params)
|
email_logs = filter_logs(email_logs, params)
|
||||||
|
|
||||||
if params[:reply_key].present?
|
if (reply_key = params[:reply_key]).present?
|
||||||
email_logs = email_logs.where(
|
email_logs =
|
||||||
"post_reply_keys.reply_key::TEXT ILIKE ?", "%#{params[:reply_key]}%"
|
if reply_key.length == 32
|
||||||
)
|
email_logs.where("post_reply_keys.reply_key = ?", reply_key)
|
||||||
|
else
|
||||||
|
email_logs.where(
|
||||||
|
"replace(post_reply_keys.reply_key::VARCHAR, '-', '') ILIKE ?",
|
||||||
|
"%#{reply_key}%"
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
email_logs = email_logs.to_a
|
email_logs = email_logs.to_a
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ class EmailLog < ActiveRecord::Base
|
|||||||
.first
|
.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bounce_key
|
||||||
|
super&.delete('-')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
|
|||||||
@@ -8,8 +8,12 @@ class PostReplyKey < ActiveRecord::Base
|
|||||||
validates :user_id, presence: true
|
validates :user_id, presence: true
|
||||||
validates :reply_key, presence: true
|
validates :reply_key, presence: true
|
||||||
|
|
||||||
|
def reply_key
|
||||||
|
super&.delete('-')
|
||||||
|
end
|
||||||
|
|
||||||
def self.generate_reply_key
|
def self.generate_reply_key
|
||||||
SecureRandom.uuid
|
SecureRandom.hex(16)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ class EmailLogSerializer < ApplicationSerializer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def reply_key
|
def reply_key
|
||||||
@options[:reply_keys][[object.post_id, object.user_id]]
|
@options[:reply_keys][[object.post_id, object.user_id]].delete("-")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ describe EmailLog do
|
|||||||
.pluck("bounce_key::text")
|
.pluck("bounce_key::text")
|
||||||
.first
|
.first
|
||||||
|
|
||||||
expect(raw_key).to eq(hex)
|
expect(raw_key).to_not eq(hex)
|
||||||
|
expect(raw_key.delete('-')).to eq(hex)
|
||||||
expect(EmailLog.find(email_log.id).bounce_key).to eq(hex)
|
expect(EmailLog.find(email_log.id).bounce_key).to eq(hex)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'rails_helper'
|
|||||||
RSpec.describe PostReplyKey do
|
RSpec.describe PostReplyKey do
|
||||||
describe "#reply_key" do
|
describe "#reply_key" do
|
||||||
it "should format the reply_key correctly" do
|
it "should format the reply_key correctly" do
|
||||||
hex = SecureRandom.uuid
|
hex = SecureRandom.hex
|
||||||
post_reply_key = Fabricate(:post_reply_key,
|
post_reply_key = Fabricate(:post_reply_key,
|
||||||
reply_key: hex
|
reply_key: hex
|
||||||
)
|
)
|
||||||
@@ -12,7 +12,8 @@ RSpec.describe PostReplyKey do
|
|||||||
.pluck("reply_key::text")
|
.pluck("reply_key::text")
|
||||||
.first
|
.first
|
||||||
|
|
||||||
expect(raw_key).to eq(hex)
|
expect(raw_key).to_not eq(hex)
|
||||||
|
expect(raw_key.delete('-')).to eq(hex)
|
||||||
expect(PostReplyKey.find(post_reply_key.id).reply_key).to eq(hex)
|
expect(PostReplyKey.find(post_reply_key.id).reply_key).to eq(hex)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ describe Admin::EmailController do
|
|||||||
)
|
)
|
||||||
|
|
||||||
[
|
[
|
||||||
"17-ff04",
|
"17ff04",
|
||||||
"2d447423-c625-4fb9-8717-ff04ac60eee8"
|
"2d447423c6254fb98717ff04ac60eee8"
|
||||||
].each do |reply_key|
|
].each do |reply_key|
|
||||||
get "/admin/email/sent.json", params: {
|
get "/admin/email/sent.json", params: {
|
||||||
reply_key: reply_key
|
reply_key: reply_key
|
||||||
|
|||||||
Reference in New Issue
Block a user