Skip to content

RSS and Telegram notifications#76

Merged
AuxiliumCDNG merged 21 commits intomasterfrom
admin-notifications
Jan 25, 2022
Merged

RSS and Telegram notifications#76
AuxiliumCDNG merged 21 commits intomasterfrom
admin-notifications

Conversation

@AuxiliumCDNG
Copy link
Copy Markdown
Contributor

@AuxiliumCDNG AuxiliumCDNG commented Oct 30, 2021

This closes #54.

I added three "feeds":
admin - contains software and hardware related alerts
warning - contains notifications regarding the bees themselves
data - contains live datasets of the API

They may be viewed with an RSS client via /rss/<feed> and /rss/<feed>/<post>.
They are also sent via Telegram if you have subscribed to them, which may be done by sending /aboniere_<feed>.

Problems:

  • @AuxiliumCDNG admin and warning need triggers and content (consulting "bee expert")
  • @fabiancdng implement some things already for the admin feed
  • @fabiancdng RSS Item Page needs a template for displaying individual "posts"

Have fun :)

@AuxiliumCDNG AuxiliumCDNG added the enhancement New feature or request label Oct 30, 2021
changed message a bit (e.g. to include feed)
fabiancdng
fabiancdng previously approved these changes Oct 31, 2021
Copy link
Copy Markdown
Member

@fabiancdng fabiancdng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feeds and subscriptions seem to work for me!
I really like your DB code refactor. Using a connection pool is certainly the best way of implementing MySQL for our use case.

Just to make sure I understand it correctly: This PR introduces the core functionalities of a notification system but it doesn't put any content in the feed or send out notifications?
Do you plan on implementing the triggers and content before merging into master or do you want (us) to do that afterwards? I'd be totally fine with contributing to that

@AuxiliumCDNG
Copy link
Copy Markdown
Contributor Author

Yep, you got it. This just implements the means to create the feeds and send them via Telegram.
I am going to consult our bee expert during the next few days to come up with a notification concept for the warning feed.

If you want, you may start adding triggers for the admin feed.
Just import the Feed class and do Feed().push_notification("admin", <title>, <text>).

The data feed needs some further coding because sending it every 30 minutes would be a bit much.
The RSS data feed may be constructed from the database from scratch but the telegram part needs some attention.

I'm excited about your changes :)

@AuxiliumCDNG
Copy link
Copy Markdown
Contributor Author

Oh, and since you are the front-end guy for the most part:
You could set up a template that the "show_article" (see /blueprints/rss.py) uses to display the post.

I am thinking about a super-simplified forum layout. There should be a back button that leads back to the main feed.
So if you are at /rss/admin/42 the back button should lead to /rss/admin. Similar to the pages feature.

@fabiancdng
Copy link
Copy Markdown
Member

Yep, you got it. This just implements the means to create the feeds and send them via Telegram. I am going to consult our bee expert during the next few days to come up with a notification concept for the warning feed.

If you want, you may start adding triggers for the admin feed. Just import the Feed class and do Feed().push_notification("admin", <title>, <text>).

The data feed needs some further coding because sending it every 30 minutes would be a bit much. The RSS data feed may be constructed from the database from scratch but the telegram part needs some attention.

I'm excited about your changes :)

Thanks for your explanation! I agree, sending out a Telegram notification every time a new data set has been measured is annoying af. Do you think something like a "summary" would make sense? So, something like sending out a notification once a day that tells you how many data sets were captured on that day (maybe with average values?) and maybe points you to the detailed RSS feed?

@fabiancdng
Copy link
Copy Markdown
Member

Oh, and since you are the front-end guy for the most part: You could set up a template that the "show_article" (see /blueprints/rss.py) uses to display the post.

I am thinking about a super-simplified forum layout. There should be a back button that leads back to the main feed. So if you are at /rss/admin/42 the back button should lead to /rss/admin. Similar to the pages feature.

I'm not at all into RSS feeds and stuff. But I'll try my best to come up with something when I get to it.

@fabiancdng fabiancdng marked this pull request as draft October 31, 2021 13:23
@fabiancdng
Copy link
Copy Markdown
Member

fabiancdng commented Oct 31, 2021

@AuxiliumCDNG Made the PR WIP for now (unless your want to merge the current changes already?). I also updated your PR description and added a to-do list.

I might be busy and not able to work on this project for a while. But I'll try to get to it ASAP.

@AuxiliumCDNG
Copy link
Copy Markdown
Contributor Author

Oh, and since you are the front-end guy for the most part: You could set up a template that the "show_article" (see /blueprints/rss.py) uses to display the post.
I am thinking about a super-simplified forum layout. There should be a back button that leads back to the main feed. So if you are at /rss/admin/42 the back button should lead to /rss/admin. Similar to the pages feature.

I'm not at all into RSS feeds and stuff. But I'll try my best to come up with something when I get to it.

You don't need to. You already get the Item with its title, text, time, and feed name. You just need to display it.

@AuxiliumCDNG
Copy link
Copy Markdown
Contributor Author

Yep, you got it. This just implements the means to create the feeds and send them via Telegram. I am going to consult our bee expert during the next few days to come up with a notification concept for the warning feed.
If you want, you may start adding triggers for the admin feed. Just import the Feed class and do Feed().push_notification("admin", <title>, <text>).
The data feed needs some further coding because sending it every 30 minutes would be a bit much. The RSS data feed may be constructed from the database from scratch but the telegram part needs some attention.
I'm excited about your changes :)

Thanks for your explanation! I agree, sending out a Telegram notification every time a new data set has been measured is annoying af. Do you think something like a "summary" would make sense? So, something like sending out a notification once a day that tells you how many data sets were captured on that day (maybe with average values?) and maybe points you to the detailed RSS feed?

Yep, that's what I was thinking...I will remove that from the todo for now and put it into a seperate issue.

AuxiliumCDNG and others added 4 commits November 2, 2021 18:42
Add ability to retrieve a feed in different formats. There's a classic
RSS (XML) option, a JSON option and an HTML option utilizing the
Feed Template.
Add HTML template for a single feed article.
Also, rename `rss.html` to `feed.html`.
Add ability to retrieve a feed article in different formats.
There's  a JSON option and an HTML option utilizing the feed
article template.
@fabiancdng
Copy link
Copy Markdown
Member

@AuxiliumCDNG I worked a little on the templating stuff and here is what I came up with:

Feeds

Each feed can now be retrieved in 3 different formats: XML (so that RSS readers can properly parse it), JSON (so we can easily use it in other projects; maybe a display implementation?) and HTML. The HTML version has a template applied so it's human-readable and sort of "interactive".

You can specify the different formats by appending ?pretty (for HTML) or ?json (for JSON) to the URL. The XML version is returned by default.

Screenshot from 2021-12-04 15-35-31

Single Articles

I also created JSON and HTML versions for "single" articles (using the same URL params). However, by default it only returns the article's text (since I couldn't figure out how to get a single post in RSS/XML format from the Notifications class, maybe you can try to implement that?).

Screenshot from 2021-12-04 15-39-02

@fabiancdng
Copy link
Copy Markdown
Member

Oh, and as you can see in the screenshot, there's now an event pushed to the admin feed when the app.py is started. Currently, it's the only useful event I can come up with but I'll keep an eye out for other use cases.

@AuxiliumCDNG
Copy link
Copy Markdown
Contributor Author

Single RSS posts don't have any formatting. They just get opened by the link they got associated with.
That's why I just asked for a template to render the post data in, which is the time, title, and text.
This also should get returned by default.
I'm gonna push that soon.

@AuxiliumCDNG
Copy link
Copy Markdown
Contributor Author

Done!
@fabiancdng Please add some useful things, like a QR code to the XML version on the pretty version.
Then you could scan it with your phone so you don't have to type the feed url by hand.

Also, please add some link on the dashboard and display so people find it? :)

@AuxiliumCDNG
Copy link
Copy Markdown
Contributor Author

AuxiliumCDNG commented Dec 4, 2021

Oh, and this...
This app (An Otter RSS...very cute, I know) plays very well with BeeLogger rss since it doesn't have all that news rss bloat and nonsense. It just works and does what you want it to do...
It is also opened by Safari if it detects an rss feed (QR code wink wink).
Give it a try :)
https://apps.apple.com/de/app/an-otter-rss-reader/id1529696614

@fabiancdng
Copy link
Copy Markdown
Member

fabiancdng commented Dec 5, 2021

@AuxiliumCDNG Nice idea with the QR code!

Added main page for feed with list of all feed

Screenshot 2021-12-05 at 12 17 47

Added QR code to RSS feed at the top of the HTML versions

Screenshot 2021-12-05 at 12 48 44

The QR code is dynamically generated using a client-side API. That means the URL isn't hard-coded so the QR code will always point to the correct domain regardless of where and how BeeLogger is deployed.

Added Iframe on Display page and Link(s) on Dashboard

TODO: Implement proper check system
@AuxiliumCDNG
Copy link
Copy Markdown
Contributor Author

I think we should merge this for now. I added a trigger for the warning feed.
Other triggers can be implemented later...

@AuxiliumCDNG AuxiliumCDNG marked this pull request as ready for review January 25, 2022 12:54
Copy link
Copy Markdown
Member

@fabiancdng fabiancdng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AuxiliumCDNG Looks good and I agree. Feel free to merge.

@AuxiliumCDNG AuxiliumCDNG merged commit 52bca15 into master Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notification service for admins

2 participants