Skip to content

Commit

Permalink
fix hound
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy-Mao committed May 16, 2022
1 parent 9a4d889 commit 3d7cd6e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
18 changes: 10 additions & 8 deletions lib/fcm/client/instance_topic_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def manage_topics_relationship(topic, registration_ids, action)

def topic_subscription(topic, registration_id)
end_point = "/iid/v1/#{registration_id}/rel/topics/#{topic}"
res = make_request(:post, INSTANCE_ID_API, end_point, nil, authorization_headers)
res = make_request(
:post, INSTANCE_ID_API, end_point, nil, authorization_headers
)
build_response(res)
end

Expand All @@ -33,26 +35,26 @@ def get_instance_id_info(iid_token, options = {})
def batch_topic_subscription(topic, registration_ids)
manage_topics_relationship(topic, registration_ids, 'Add')
end

def batch_topic_unsubscription(topic, registration_ids)
manage_topics_relationship(topic, registration_ids, 'Remove')
end

def batch_subscribe_instance_ids_to_topic(instance_ids, topic_name)
manage_topics_relationship(topic_name, instance_ids, 'Add')
end

def batch_unsubscribe_instance_ids_from_topic(instance_ids, topic_name)
manage_topics_relationship(topic_name, instance_ids, 'Remove')
end

def subscribe_instance_id_to_topic(iid_token, topic_name)
batch_subscribe_instance_ids_to_topic([iid_token], topic_name)
end

def unsubscribe_instance_id_from_topic(iid_token, topic_name)
batch_unsubscribe_instance_ids_from_topic([iid_token], topic_name)
end
end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/fcm/client/notification_delivery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ def validate_condition?(condition)
condition
)
end

def validate_condition_format?(condition)
bad_characters = condition.gsub(
/(topics|in|\s|\(|\)|(&&)|[!]|(\|\|)|'([a-zA-Z0-9\-_.~%]+)')/,
''
)
bad_characters.length.zero?
end

def validate_condition_topics?(condition)
topics = condition.scan(/(?:^|\S|\s)'([^']*?)'(?:$|\S|\s)/).flatten
topics.all? { |topic| topic.gsub(TOPIC_REGEX, '').length.zero? }
Expand Down
6 changes: 3 additions & 3 deletions lib/fcm/client_v1/notification_delivery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ module NotificationDilivery

def send_notification_v1(message, project_name)
return if project_name.empty?

post_body = { 'message': message }
end_point = "#{project_name}/messages:send"

res = make_request(
:post, BASE_URI_V1, end_point, post_body.to_json, authorization_headers
)
build_response(res)
end
end
end
end
end

0 comments on commit 3d7cd6e

Please sign in to comment.