# == Schema Information
#
# Table name: webhook
#
#  id                :integer          not null, primary key
#  repo_id           :integer
#  org_id            :integer
#  is_system_webhook :boolean
#  url               :text(65535)
#  http_method       :string(255)
#  content_type      :integer
#  secret            :text(65535)
#  events            :text(65535)
#  is_active         :boolean
#  type              :string(16)
#  meta              :text(65535)
#  last_status       :integer
#  created_unix      :integer
#  updated_unix      :integer
#
# Indexes
#
#  IDX_webhook_created_unix  (created_unix)
#  IDX_webhook_is_active     (is_active)
#  IDX_webhook_org_id        (org_id)
#  IDX_webhook_repo_id       (repo_id)
#  IDX_webhook_updated_unix  (updated_unix)
#

class Gitea::Webhook < Gitea::Base
  serialize :events, JSON
  self.inheritance_column = nil

  self.table_name = 'webhook'
  
  has_many :tasks, class_name: "Gitea::WebhookTask", foreign_key: :hook_id
  belongs_to :project, class_name: "::Project", primary_key: :gpid, foreign_key: :repo_id, optional: true

  enum hook_task_type: {gogs: 1, slack: 2, gitea: 3, discord: 4, dingtalk: 5, telegram: 6, msteams: 7, feishu: 8, matrix: 9}
  enum last_status: {waiting: 0, succeed: 1, fail: 2}
  enum content_type: {json: 1, form: 2}
end
