Giter Club home page Giter Club logo

Comments (5)

YoRyan avatar YoRyan commented on July 30, 2024 1

Now available with b76b164. πŸ‘

from mailrise.

wardellbagby avatar wardellbagby commented on July 30, 2024

So I have a working branch following my initial message I'll push up in the morning for your thoughts on (it's even got tests!) but thinking more about this, maybe it's better to instead extend the existing templating logic with extra variables?

So something like:

configs:
  "*@*":
    mailrise:
      extra_body_variables:
        - name: '(?<=<h1>).+(?=<\/h1>)
        - type: '(?<=<p>).+(?=<\/p>)'
       body_template: '$name, $type'
    urls:
      - tgram://...

Where then giving it an email body of:

<html><h1>Wardell</h1><p>Super cool programmer</p>

Would then call Apprise like:

apprise --body="Wardell, Super cool programmer"

from mailrise.

YoRyan avatar YoRyan commented on July 30, 2024

Ooh, I appreciate the PR, and the tests. I'm also pleased that you had a chance to work with the code that I had just finished refactoring.

But to be honest, I'm not keen on adding any additional options to the YAML configuration file. I'd like to keep that format simple, so any homelabber can hit the ground running with itβ€”what I'd like to do instead is make it possible to supply your own Python class to determine the processing logic. (If you're the type to delve into regexes, you most likely aren't afraid of getting your hands dirty with a little Python, methinks.) In short, you'd be able to write your own SimpleRouter.

I'll have it done soon; I've just been debating the semantics. I'm thinking something like:

mailrise.conf:

python_logic: /path/to/my/logic.py
...

logic.py:

class MyCustomRouter():
    async def email_to_apprise(self, logger, email):
        ...
        yield AppriseNotification(...)

router = MyCustomRouter()

I believe such custom routers will provide the most flexibility for users interested in fine-tuning their notifications.

from mailrise.

wardellbagby avatar wardellbagby commented on July 30, 2024

Hahaha, wow, great minds do think alike!

I love your custom_router approach here and I'm fully okay with just waiting for that to get in.

That being said, while I think that's a great fit for anyone building from source, it'll be a little weird for anyone using Docker. Mainly because they'll likely have to check out the project anyway to get the right typings and then have their Dockerfile copy over their custom router.

Of course, it's Python and the types don't actually matter but it's going to feel a little odd to write a custom router against one version of Mailrise that might end up running in a different version. That's going to be on the users to keep in sync and I don't think it's overly-difficult, just something to remember as updates happen.

from mailrise.

YoRyan avatar YoRyan commented on July 30, 2024

That being said, while I think that's a great fit for anyone building from source, it'll be a little weird for anyone using Docker. Mainly because they'll likely have to check out the project anyway to get the right typings and then have their Dockerfile copy over their custom router.

Not necessarily. You'll be able to passthrough the .py file just like you can do with the config file itself:

-v /path/to/my/config.yml:/etc/mailrise.conf
-v /path/to/my/pluggable.py:/etc/mailrise_logic.py

That's going to be on the users to keep in sync and I don't think it's overly-difficult, just something to remember as updates happen.

Of course. It's important to design an API that will be unlikely to change.

from mailrise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.