FIX: properly ban non human users from draft system

Previously we had a partial fix in place where non human users
were not allowed draft sequences, this left edges around where non
human users asked for drafts yet had none.

For example system could already have a few drafts in place.

This also removes and extensibility point we added that is not in use
This commit is contained in:
Sam Saffron
2020-05-26 10:07:00 +10:00
parent 979093787f
commit fc97f7e0e7
5 changed files with 31 additions and 23 deletions

View File

@@ -12,6 +12,22 @@ describe Draft do
Fabricate(:post)
end
context 'system user' do
it "can not set drafts" do
# fake a sequence
DraftSequence.create!(user_id: Discourse.system_user.id, draft_key: "abc", sequence: 10)
seq = Draft.set(Discourse.system_user, "abc", 0, { reply: 'hi' }.to_json)
expect(seq).to eq(0)
draft = Draft.get(Discourse.system_user, "abc", 0)
expect(draft).to eq(nil)
draft = Draft.get(Discourse.system_user, "abc", 1)
expect(draft).to eq(nil)
end
end
context 'backup_drafts_to_pm_length' do
it "correctly backs up drafts to a personal message" do
SiteSetting.backup_drafts_to_pm_length = 1