Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for condition field #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

ks0m1c
Copy link

@ks0m1c ks0m1c commented Oct 27, 2022

Naive implementation of incorporating conditions for pushing messages to topics.

condition | Optional, string | This parameter specifies a logical expression of conditions that determine the message target.

Supported condition: Topic, formatted as "'yourTopic' in topics". This value is case-insensitive. Supported operators: &&, \|\|. Maximum two operators per topic message supported.

Current library is built around the to field, however using condition field collides with the 'to' field. As below:

{:error, "Must use either \"registration_ids\" field or \"to\" field or \"condition\", not more than one\n"}

As such to support condition field, I have prevented the merge of the to field

Willing to add in the test cases and update docs if satisfactory.

Fcmex.push("Messages all of Athens but not Pheidippides",
  notification: %{
    title: "CITY.Athens not USER.Pheidippides",
    body: "Rejoice, we conquer"
  },
  condition: "'CITY.Athens' in topics && !('USER.Pheidippides' in topics)"
)

κϩⲐⲡⲓז‎ς_ⲙ0ᚱⲣⲉ𐤅ᛊ added 3 commits October 28, 2022 00:42
Motivation: To pattern match the condition option match to more cleanly
ignore the to field

Quoting from Erlang OTP team => https://erlangforums.com/t/handling-options-in-erlang-otp-apis/1133
Briefly, the main motivation for avoiding lists unless necessary, is that given the option list [{use_foo,true}, {use_foo,false}] the value of the use_foo is not immediately clear. Existing OTP APIs that use options are not consistent in that regard. With maps, that ambiguity cannot arise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant