mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add external_id to topics (#15825)
* FEATURE: Add external_id to topics This commit allows for topics to be created and fetched by an external_id. These changes are API only for now as there aren't any front changes. * add annotations * add external_id to this spec * Several PR feedback changes - Add guardian to find topic - 403 is returned for not found as well now - add `include_external_id?` - external_id is now case insensitive - added test for posts_controller - added test for topic creator - created constant for max length - check that it redirects to the correct path - restrain external id in routes file * remove puts * fix tests * only check for external_id in webhook if exists * Update index to exclude external_id if null * annotate * Update app/controllers/topics_controller.rb We need to check whether the topic is present first before passing it to the guardian. Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com> * Apply suggestions from code review Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com> Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
8
db/migrate/20220202225716_add_external_id_to_topics.rb
Normal file
8
db/migrate/20220202225716_add_external_id_to_topics.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddExternalIdToTopics < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :topics, :external_id, :string, null: true
|
||||
add_index :topics, :external_id, unique: true, where: 'external_id IS NOT NULL'
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user