feat: Add Public APIs for API Channel (#2375)

This commit is contained in:
Sojan Jose
2021-06-15 20:09:17 +05:30
committed by GitHub
parent 0f377da109
commit 853db60f8e
29 changed files with 404 additions and 11 deletions

View File

@@ -0,0 +1,19 @@
class AddHmacToApiChannel < ActiveRecord::Migration[6.0]
def change
add_column :channel_api, :identifier, :string
add_index :channel_api, :identifier, unique: true
add_column :channel_api, :hmac_token, :string
add_index :channel_api, :hmac_token, unique: true
add_column :channel_api, :hmac_mandatory, :boolean, default: false
add_column :channel_web_widgets, :hmac_mandatory, :boolean, default: false
set_up_existing_api_channels
end
def set_up_existing_api_channels
::Channel::Api.find_in_batches do |api_channels_batch|
Rails.logger.info "migrated till #{api_channels_batch.first.id}\n"
api_channels_batch.map(&:regenerate_hmac_token)
api_channels_batch.map(&:regenerate_identifier)
end
end
end

View File

@@ -143,6 +143,11 @@ ActiveRecord::Schema.define(version: 2021_06_09_133433) do
t.string "webhook_url"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "identifier"
t.string "hmac_token"
t.boolean "hmac_mandatory", default: false
t.index ["hmac_token"], name: "index_channel_api_on_hmac_token", unique: true
t.index ["identifier"], name: "index_channel_api_on_identifier", unique: true
end
create_table "channel_email", force: :cascade do |t|
@@ -201,6 +206,7 @@ ActiveRecord::Schema.define(version: 2021_06_09_133433) do
t.string "hmac_token"
t.boolean "pre_chat_form_enabled", default: false
t.jsonb "pre_chat_form_options", default: {}
t.boolean "hmac_mandatory", default: false
t.index ["hmac_token"], name: "index_channel_web_widgets_on_hmac_token", unique: true
t.index ["website_token"], name: "index_channel_web_widgets_on_website_token", unique: true
end