mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-04 04:57:51 +00:00 
			
		
		
		
	@@ -33,6 +33,10 @@ jobs:
 | 
				
			|||||||
          name: Bundle Install
 | 
					          name: Bundle Install
 | 
				
			||||||
          command: bundle check || bundle install
 | 
					          command: bundle check || bundle install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - run:
 | 
				
			||||||
 | 
					          name: Rubocop
 | 
				
			||||||
 | 
					          command: bundle exec rubocop
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      # Store bundle cache
 | 
					      # Store bundle cache
 | 
				
			||||||
      - save_cache:
 | 
					      - save_cache:
 | 
				
			||||||
          key: chatwoot-bundle-v2-{{ checksum "Gemfile.lock" }}
 | 
					          key: chatwoot-bundle-v2-{{ checksum "Gemfile.lock" }}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								.rubocop.yml
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								.rubocop.yml
									
									
									
									
									
								
							@@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					inherit_from: .rubocop_todo.yml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Metrics/LineLength:
 | 
					Metrics/LineLength:
 | 
				
			||||||
  Max: 150
 | 
					  Max: 150
 | 
				
			||||||
Documentation:
 | 
					Documentation:
 | 
				
			||||||
@@ -8,5 +10,15 @@ Style/SymbolArray:
 | 
				
			|||||||
  Enabled: false
 | 
					  Enabled: false
 | 
				
			||||||
Metrics/BlockLength:
 | 
					Metrics/BlockLength:
 | 
				
			||||||
  Exclude:
 | 
					  Exclude:
 | 
				
			||||||
    - db/migrate/**/*
 | 
					 | 
				
			||||||
    - spec/**/*
 | 
					    - spec/**/*
 | 
				
			||||||
 | 
					Style/ClassAndModuleChildren:
 | 
				
			||||||
 | 
					  EnforcedStyle: compact
 | 
				
			||||||
 | 
					AllCops:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - db/*
 | 
				
			||||||
 | 
					    - bin/**/*
 | 
				
			||||||
 | 
					    - db/**/*
 | 
				
			||||||
 | 
					    - config/**/*
 | 
				
			||||||
 | 
					    - public/**/*
 | 
				
			||||||
 | 
					    - vendor/**/*
 | 
				
			||||||
 | 
					    - node_modules/**/*
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										184
									
								
								.rubocop_todo.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										184
									
								
								.rubocop_todo.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,184 @@
 | 
				
			|||||||
 | 
					# This configuration was generated by
 | 
				
			||||||
 | 
					# `rubocop --auto-gen-config`
 | 
				
			||||||
 | 
					# on 2019-10-20 22:59:04 +0300 using RuboCop version 0.75.1.
 | 
				
			||||||
 | 
					# The point is for the user to remove these configuration records
 | 
				
			||||||
 | 
					# one by one as the offenses are removed from the code base.
 | 
				
			||||||
 | 
					# Note that changes in the inspected code, or installation of new
 | 
				
			||||||
 | 
					# versions of RuboCop, may require this file to be generated again.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					# Configuration parameters: EnforcedStyle.
 | 
				
			||||||
 | 
					# SupportedStyles: native, lf, crlf
 | 
				
			||||||
 | 
					Layout/EndOfLine:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'deploy/after_restart.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					Lint/DuplicateMethods:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/reports_controller.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					Lint/RescueException:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/builders/messages/message_builder.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 4
 | 
				
			||||||
 | 
					Lint/ShadowingOuterLocalVariable:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/reports_controller.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 3
 | 
				
			||||||
 | 
					# Configuration parameters: AllowKeywordBlockArguments.
 | 
				
			||||||
 | 
					Lint/UnderscorePrefixedVariableName:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/models/account.rb'
 | 
				
			||||||
 | 
					    - 'deploy/before_symlink.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 18
 | 
				
			||||||
 | 
					Lint/UselessAssignment:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/callbacks_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/facebook_indicators_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/listeners/pusher_listener.rb'
 | 
				
			||||||
 | 
					    - 'app/listeners/reporting_listener.rb'
 | 
				
			||||||
 | 
					    - 'app/models/channel/facebook_page.rb'
 | 
				
			||||||
 | 
					    - 'app/models/facebook_page.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 14
 | 
				
			||||||
 | 
					Metrics/AbcSize:
 | 
				
			||||||
 | 
					  Max: 26
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					# Configuration parameters: CountComments, ExcludedMethods.
 | 
				
			||||||
 | 
					# ExcludedMethods: refine
 | 
				
			||||||
 | 
					Metrics/BlockLength:
 | 
				
			||||||
 | 
					  Max: 30
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 2
 | 
				
			||||||
 | 
					Metrics/CyclomaticComplexity:
 | 
				
			||||||
 | 
					  Max: 7
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 4
 | 
				
			||||||
 | 
					# Cop supports --auto-correct.
 | 
				
			||||||
 | 
					# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
 | 
				
			||||||
 | 
					# URISchemes: http, https
 | 
				
			||||||
 | 
					Metrics/LineLength:
 | 
				
			||||||
 | 
					  Max: 497
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 9
 | 
				
			||||||
 | 
					# Configuration parameters: CountComments, ExcludedMethods.
 | 
				
			||||||
 | 
					Metrics/MethodLength:
 | 
				
			||||||
 | 
					  Max: 19
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					Metrics/PerceivedComplexity:
 | 
				
			||||||
 | 
					  Max: 8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 6
 | 
				
			||||||
 | 
					Naming/AccessorMethodName:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/builders/report_builder.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/accounts_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/callbacks_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/conversations_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/passwords_controller.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 9
 | 
				
			||||||
 | 
					# Configuration parameters: EnforcedStyleForLeadingUnderscores.
 | 
				
			||||||
 | 
					# SupportedStylesForLeadingUnderscores: disallowed, required, optional
 | 
				
			||||||
 | 
					Naming/MemoizedInstanceVariableName:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/controllers/api/base_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/conversations_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/webhooks_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/application_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/models/message.rb'
 | 
				
			||||||
 | 
					    - 'lib/integrations/widget/outgoing_message_builder.rb'
 | 
				
			||||||
 | 
					    - 'lib/webhooks/chargebee.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 15
 | 
				
			||||||
 | 
					# Cop supports --auto-correct.
 | 
				
			||||||
 | 
					# Configuration parameters: AutoCorrect, EnforcedStyle.
 | 
				
			||||||
 | 
					# SupportedStyles: nested, compact
 | 
				
			||||||
 | 
					Style/ClassAndModuleChildren:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/builders/messages/message_builder.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/inbox_members_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/models/channel/facebook_page.rb'
 | 
				
			||||||
 | 
					    - 'app/models/channel/web_widget.rb'
 | 
				
			||||||
 | 
					    - 'app/presenters/conversations/event_data_presenter.rb'
 | 
				
			||||||
 | 
					    - 'app/services/facebook/send_reply_service.rb'
 | 
				
			||||||
 | 
					    - 'lib/integrations/facebook/delivery_status.rb'
 | 
				
			||||||
 | 
					    - 'lib/integrations/facebook/message_creator.rb'
 | 
				
			||||||
 | 
					    - 'lib/integrations/facebook/message_parser.rb'
 | 
				
			||||||
 | 
					    - 'lib/integrations/widget/incoming_message_builder.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 4
 | 
				
			||||||
 | 
					Style/CommentedKeyword:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/callbacks_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/conversations/assignments_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/conversations/labels_controller.rb'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/labels_controller.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					# Configuration parameters: EnforcedStyle.
 | 
				
			||||||
 | 
					# SupportedStyles: annotated, template, unannotated
 | 
				
			||||||
 | 
					Style/FormatStringToken:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'lib/constants/redis_keys.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 4
 | 
				
			||||||
 | 
					# Configuration parameters: AllowedVariables.
 | 
				
			||||||
 | 
					Style/GlobalVars:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'lib/redis/alfred.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 7
 | 
				
			||||||
 | 
					# Configuration parameters: MinBodyLength.
 | 
				
			||||||
 | 
					Style/GuardClause:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/builders/account_builder.rb'
 | 
				
			||||||
 | 
					    - 'app/models/attachment.rb'
 | 
				
			||||||
 | 
					    - 'app/models/message.rb'
 | 
				
			||||||
 | 
					    - 'lib/webhooks/chargebee.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 4
 | 
				
			||||||
 | 
					Style/IdenticalConditionalBranches:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/reports_controller.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					# Configuration parameters: AllowIfModifier.
 | 
				
			||||||
 | 
					Style/IfInsideElse:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/finders/conversation_finder.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					# Cop supports --auto-correct.
 | 
				
			||||||
 | 
					Style/IfUnlessModifier:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'deploy/before_symlink.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					Style/MixinUsage:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/bot/bot.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					# Cop supports --auto-correct.
 | 
				
			||||||
 | 
					# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
 | 
				
			||||||
 | 
					# SupportedStyles: predicate, comparison
 | 
				
			||||||
 | 
					Style/NumericPredicate:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'spec/**/*'
 | 
				
			||||||
 | 
					    - 'app/controllers/api/v1/callbacks_controller.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Offense count: 1
 | 
				
			||||||
 | 
					# Cop supports --auto-correct.
 | 
				
			||||||
 | 
					# Configuration parameters: EnforcedStyle.
 | 
				
			||||||
 | 
					# SupportedStyles: implicit, explicit
 | 
				
			||||||
 | 
					Style/RescueStandardError:
 | 
				
			||||||
 | 
					  Exclude:
 | 
				
			||||||
 | 
					    - 'app/models/channel/facebook_page.rb'
 | 
				
			||||||
@@ -10,7 +10,10 @@ class Api::V1::CallbacksController < ApplicationController
 | 
				
			|||||||
    page_name = params[:page_name]
 | 
					    page_name = params[:page_name]
 | 
				
			||||||
    page_id = params[:page_id]
 | 
					    page_id = params[:page_id]
 | 
				
			||||||
    inbox_name = params[:inbox_name]
 | 
					    inbox_name = params[:inbox_name]
 | 
				
			||||||
    facebook_channel = current_account.facebook_pages.create!(name: page_name, page_id: page_id, user_access_token: user_access_token, page_access_token: page_access_token, remote_avatar_url: set_avatar(page_id))
 | 
					    facebook_channel = current_account.facebook_pages.create!(
 | 
				
			||||||
 | 
					      name: page_name, page_id: page_id, user_access_token: user_access_token,
 | 
				
			||||||
 | 
					      page_access_token: page_access_token, remote_avatar_url: set_avatar(page_id)
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
    inbox = current_account.inboxes.create!(name: inbox_name, channel: facebook_channel)
 | 
					    inbox = current_account.inboxes.create!(name: inbox_name, channel: facebook_channel)
 | 
				
			||||||
    render json: inbox
 | 
					    render json: inbox
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,6 +44,15 @@ class Inbox < ApplicationRecord
 | 
				
			|||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def subscribe_webhook
 | 
					  def subscribe_webhook
 | 
				
			||||||
    Facebook::Messenger::Subscriptions.subscribe(access_token: channel.page_access_token, subscribed_fields: %w[message_mention messages messaging_account_linking messaging_checkout_updates message_echoes message_deliveries messaging_game_plays messaging_optins messaging_optouts messaging_payments messaging_postbacks messaging_pre_checkouts message_reads messaging_referrals messaging_handovers messaging_policy_enforcement messaging_page_feedback messaging_appointments messaging_direct_sends])
 | 
					    Facebook::Messenger::Subscriptions.subscribe(
 | 
				
			||||||
 | 
					      access_token: channel.page_access_token,
 | 
				
			||||||
 | 
					      subscribed_fields: %w[
 | 
				
			||||||
 | 
					        message_mention messages messaging_account_linking messaging_checkout_updates
 | 
				
			||||||
 | 
					        message_echoes message_deliveries messaging_game_plays messaging_optins messaging_optouts
 | 
				
			||||||
 | 
					        messaging_payments messaging_postbacks messaging_pre_checkouts message_reads messaging_referrals
 | 
				
			||||||
 | 
					        messaging_handovers messaging_policy_enforcement messaging_page_feedback
 | 
				
			||||||
 | 
					        messaging_appointments messaging_direct_sends
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,8 +33,12 @@ if %w[application sidekiq whenever].include? node[:opsworks][:instance][:layers]
 | 
				
			|||||||
    # end
 | 
					    # end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # migrations
 | 
					    # migrations
 | 
				
			||||||
    master_node = node[:opsworks][:layers]['application'][:instances].keys.min if node[:opsworks][:layers] && node[:opsworks][:layers]['application'] && node[:opsworks][:layers]['application'][:instances]
 | 
					    if  (node[:opsworks][:layers] && node[:opsworks][:layers]['application']) &&
 | 
				
			||||||
    if master_node && node[:opsworks][:instance][:hostname].include?(master_node)
 | 
					        (endnode[:opsworks][:layers]['application'][:instances])
 | 
				
			||||||
 | 
					      master_node = node[:opsworks][:layers]['application'][:instances].keys.min
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if master_node && :node[:opsworks][:instance][:hostname].include?(master_node)
 | 
				
			||||||
      execute 'rake db:migrate' do
 | 
					      execute 'rake db:migrate' do
 | 
				
			||||||
        cwd release_path
 | 
					        cwd release_path
 | 
				
			||||||
        command 'bundle exec rake db:migrate --trace'
 | 
					        command 'bundle exec rake db:migrate --trace'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,7 +68,3 @@ end
 | 
				
			|||||||
#     }
 | 
					#     }
 | 
				
			||||||
#   }
 | 
					#   }
 | 
				
			||||||
# }
 | 
					# }
 | 
				
			||||||
 | 
					 | 
				
			||||||
# ECHO from own app
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# {"sender"=>{"id"=>"379460302081528"}, "recipient"=>{"id"=>"403092229814994"}, "timestamp"=>1493270145685, "message"=>{"is_echo"=>true, "app_id"=>1847193292179369, "mid"=>"mid.$cAAED7rlYNsVh3xtylVbrdYqH8iEp", "seq"=>167221, "text"=>"sad"}}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user