caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
10.94k stars 385 forks source link

Improved YAML group support #998

Closed caronc closed 7 months ago

caronc commented 7 months ago

Description:

Related issue (if applicable): #952, and apprise-api/146

Current design of Tag Group handling works great as long as YAML definitions are in a list format only. e.g:

groups:
  - group1: tagB, tagC, tagNotAssigned
  - group2:
      - tagA
      - tagC
  - group3:
      - tagD: optional comment
      - tagA: optional comment #2

However the following is not supported (until this PR):

groups:
  group1: tagB, tagC, tagNotAssigned
  group2:
     - tagA
     - tagC
  group3:
     - tagD: optional comment
     - tagA: optional comment #2

It is worth noting that the trade-off (or perk, however you see it) with the new dict approach is that you can not stack entries and have them all append to one another. With the dict approach, the last defined entry prevails:

For example:

# duplicate group tags with the same name stack:
groups:
  - group: tagB, tagC
  - group: tagA

  # At this point, group == tagA, tagB and tagC

The new supported dict version behaves differently:

# duplicate group tags with the same name stack:
groups:
  group: tagB, tagC
  group: tagA

  # At this point, group == tagA (because it was the last entry defined and replaces
  # the previous value)

Checklist

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@952-group-handling-fix

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  <apprise url related to ticket>