Skip to content

Commit a8acfce

Browse files
authored
FIX: Allow topic title editing for non-ActivityPub posts (#235)
Fixes an edge case where updating the topic title of a non-ActivityPub post would raise an error when making the edit via the OP's composer.
1 parent 501ee5a commit a8acfce

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

plugin.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ module ::DiscourseActivityPub
361361
end
362362
end
363363
on(:post_edited) do |post, topic_changed, post_revisor|
364-
if post.activity_pub_full_topic && post_revisor.topic_title_changed?
364+
if post.activity_pub_full_topic && post_revisor.topic_title_changed? &&
365+
post.topic.activity_pub_object
365366
post.topic.activity_pub_object.name = post.topic.activity_pub_name
366367
post.topic.activity_pub_object.save!
367368
end

spec/lib/post_revisor_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,15 @@
140140
end
141141
end
142142
end
143+
144+
context "when revising a non-activity-pub post" do
145+
context "with full_topic enabled" do
146+
before { toggle_activity_pub(category, publication_type: "full_topic") }
147+
it "allows updating the topic title" do
148+
new_title = "New topic title"
149+
expect { post_revisor.revise!(user, title: new_title) }.not_to raise_error
150+
end
151+
end
152+
end
143153
end
144154
end

0 commit comments

Comments
 (0)