remove follow_type for now
This commit is contained in:
parent
8e9fde5504
commit
323f0b5071
5 changed files with 4 additions and 61 deletions
|
@ -4,18 +4,16 @@ class Follow < ApplicationRecord
|
|||
belongs_to :user
|
||||
belongs_to :followed, polymorphic: true
|
||||
has_one :follow_reason, dependent: :destroy
|
||||
has_one :follow_type, dependent: :destroy
|
||||
|
||||
validates :user, presence: true
|
||||
validates :followed, presence: true
|
||||
validates :user, uniqueness: { scope: :followed, message: 'This entity is already followed by this user' }
|
||||
|
||||
after_create :add_subsettings
|
||||
after_create :add_subsetting
|
||||
|
||||
private
|
||||
|
||||
def add_subsettings
|
||||
def add_subsetting
|
||||
follow_reason = FollowReason.create!(follow: self)
|
||||
follow_type = FollowType.create!(follow: self)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
class FollowType < ApplicationRecord
|
||||
belongs_to :follow
|
||||
|
||||
validates :follow, presence: true
|
||||
end
|
|
@ -96,9 +96,7 @@ class NotificationService
|
|||
end
|
||||
|
||||
def self.notify_followers(entity, event_type, event, reason_filter = nil, exclude_follows = nil)
|
||||
follows = entity.follows.joins(:follow_type).where("follow_types.all = ? OR follow_types.#{event_type} = ?", true, true)
|
||||
|
||||
follows = follows.where.not(user_id: event.user.id)
|
||||
follows = entity.follows.joins(:follow_type).where.not(user_id: event.user.id)
|
||||
|
||||
if exclude_follows
|
||||
follows = follows.where.not(id: exclude_follows)
|
||||
|
@ -114,8 +112,6 @@ class NotificationService
|
|||
return follows.map(&:id)
|
||||
end
|
||||
|
||||
|
||||
# TODO: refactor this
|
||||
def self.access_request(request)
|
||||
event_type = 'access_request'
|
||||
template = get_template_for_event_type(event_type)
|
||||
|
@ -125,7 +121,6 @@ class NotificationService
|
|||
request.map.user.notify(subject, body, request, false, mailboxer_code, true, request.user)
|
||||
end
|
||||
|
||||
# TODO: refactor this
|
||||
def self.access_approved(request)
|
||||
event_type = 'access_approved'
|
||||
template = get_template_for_event_type(event_type)
|
||||
|
@ -135,7 +130,6 @@ class NotificationService
|
|||
request.user.notify(subject, body, request, false, mailboxer_code, true, request.map.user)
|
||||
end
|
||||
|
||||
# TODO: refactor this
|
||||
def self.invite_to_edit(user_map)
|
||||
event_type = 'invite_to_edit'
|
||||
template = get_template_for_event_type(event_type)
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
class CreateFollowTypes < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :follow_types do |t|
|
||||
t.references :follow, index: true
|
||||
t.boolean :all, default: true
|
||||
t.boolean :acccess_approved
|
||||
t.boolean :access_request
|
||||
t.boolean :invite_to_edit
|
||||
t.boolean :map_activity
|
||||
t.boolean :map_collaborator_added
|
||||
t.boolean :map_message
|
||||
t.boolean :map_starred
|
||||
t.boolean :map_updated
|
||||
t.boolean :topic_added_to_map
|
||||
t.boolean :topic_connected
|
||||
t.boolean :topic_deleted
|
||||
t.boolean :topic_disconnected
|
||||
t.boolean :topic_updated
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
23
db/schema.rb
23
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170209215920) do
|
||||
ActiveRecord::Schema.define(version: 20170209215911) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -80,27 +80,6 @@ ActiveRecord::Schema.define(version: 20170209215920) do
|
|||
t.index ["follow_id"], name: "index_follow_reasons_on_follow_id", using: :btree
|
||||
end
|
||||
|
||||
create_table "follow_types", force: :cascade do |t|
|
||||
t.integer "follow_id"
|
||||
t.boolean "all", default: true
|
||||
t.boolean "acccess_approved"
|
||||
t.boolean "access_request"
|
||||
t.boolean "invite_to_edit"
|
||||
t.boolean "map_activity"
|
||||
t.boolean "map_collaborator_added"
|
||||
t.boolean "map_message"
|
||||
t.boolean "map_starred"
|
||||
t.boolean "map_updated"
|
||||
t.boolean "topic_added_to_map"
|
||||
t.boolean "topic_connected"
|
||||
t.boolean "topic_deleted"
|
||||
t.boolean "topic_disconnected"
|
||||
t.boolean "topic_updated"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["follow_id"], name: "index_follow_types_on_follow_id", using: :btree
|
||||
end
|
||||
|
||||
create_table "follows", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.boolean "email", default: true
|
||||
|
|
Loading…
Add table
Reference in a new issue