Skip to content

Let your users to be notified about the content they are interested in.

License

Notifications You must be signed in to change notification settings

eea/eea.notifications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eea.notifications

Let your users to be notified about the content they are interested in.

Mockup

📖 Usage

👶 Simple user

An user creates a subscription and manages his/hers subscriptions (in /@@manage_subscriptions form).

Manage subscriptions form

An example subscription is "notify me on new content created that is tagged ..." (which includes both new content with interest tag, or old content that gets the interest tag), "notify me on any changes that affect content with interest tag".

👨 Admin user

🏭 Installation

Add eea.notifications in your buildout. Don't forget to Activate it. Also activate eea.rabbitmq.plone else you will receive KeyError: 'Interface eea.rabbitmq.plone.rabbitmq.IRabbitMQClientSettings defines a field username, for which there is no record.' when trying to set RabbitMQ.

Administator sets content rules to ping RabbitMQ on content changes.

📬 Content rules for RabbitMQ pings

This means in /@@rules-controlpanel you will add a rule for each case. Examples: when an object is added, or modified, or removed...

Manage content rules 1

the performed action is Ping RMQ. Manage content rules 2

Defined something like: Manage content rules 3

Why a ping based on a content rule? The site administrator can decide for which content types this notification mechanism applies, thus applying a “sane default” for the users.

📭 Content rules for sending notifications

You can choose to send email notifications. In this case you will set a content rule with Event trigger: EEA Notifications: send notification event and this details:

Manage content rules b 1

Action: send email. Manage content rules b 2

In email notification you can use the substitution variables: Manage content rules b 3

as listed in this table. Manage content rules b 4

Administator sets the RabbitMQ client settings (in /@@rabbitmq-client-controlpanel).

RabbitMQ client settings

Get IP:

    $ docker inspect 8b51d27e0306 | grep "IPAddress"                                                                                    4016ms  Mon 27 Aug 2018 12:08:18 PM EEST
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.26.0.2"

Instead of 8b51d27e0306 you will use the ID of rabbitmq docker container.

Notifications center

An asynchronous script will process the pings (retrieve them from RabbitMQ) in order to send notification for all subscribed users in that case (tag + action).

$ bin/zeo_client run bin/notifications_center

Testing

Add in buildout.cfg:

parts +=
    test

[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs =
    eea.notifications [test]
    plone.testing [test]
    plone.app.testing [test]

Run the tests using:

./bin/test -s eea.notifications

Learn more: https://docs.plone.org/4/en/manage/deploying/testing_tuning/testing_and_debugging/unit_testing.html

Development: Testing emails (docker)

Add in your docker-compose:

  postfix:
    image: eaudeweb/mailtrap
    ports:
      - "8081:80"

In mail settings (@@mail-controlpanel): SMTP server: postfix SMTP port: 25

then http://localhost:8081 u: mailtrap p: mailtrap

Development: Testing RabbitMQ (docker)

In your docker-compose:

rabbitmq:
    image: rabbitmq:3-management
    hostname: eea-rabbit
    restart: always
    ports:
        - 5672:5672 # port for the daemon API, can be exposed to public.
        - 15672:15672 # port for the Management interface
    env_file:
        - .secret
    volumes:
        - /etc/localtime:/etc/localtime:ro
    volumes_from:
        - rabbitmqdata

  rabbitmqdata:
    image: busybox
    tty: true
    command: chown -v -R 999:999 /var/lib/rabbitmq
    volumes:
        - /var/lib/rabbitmq
    stdin_open: true

In your secret file:

RABBITMQ_DEFAULT_USER=admin
RABBITMQ_DEFAULT_PASS=admin

(^ Probably just to skip some errors. I don't use it.)

Then: http://0.0.0.0:15672 u: guest p: guest

📖 Demonstration

When we edit a folder with title "Nice folder title here" tagged with "Austria" tag, the RabbitMQ receive a ping with related details.

RabbitMQ

Then the notification center will search the users subscribed to this type of notifications and it will send the notifications to users.

Mailtrap

⭐ Source code

Latest source code (Plone 4 compatible): https://github.com/eea/eea.notifications/

©️ Copyright and license

The Initial Owner of the Original Code is European Environment Agency (EEA). All Rights Reserved.

More details: LICENSE file.

💰 Funding

EEA - European Environment Agency (EU)

About

Let your users to be notified about the content they are interested in.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published