| src | ||
| test | ||
| .gitignore | ||
| gleam.toml | ||
| manifest.toml | ||
| README.md | ||
stag_net
This is a project to listen to an image repository for new posts. A post is a file that
consists of a list of tags applied to it. This application allows users to register tag_groups
which are either a Watch group or a Block group. Images which match a user's Watch group and
do not match a Block group are sent to the user.
Notification Architecture
Note: this is not the most efficient way to do this. I just want to play with the OTP model
- A
rootlevel notification engine - A
usernotification engine per user - A
tag_groupnotification engine per user's tag groups
root notification has many children, user notification has many children, tag_group has no children
Post received from image API -> root notification engine -> user 1 -> tag_group 1
-> tag_group 2
-> user 2 -> tag_group 3
-> tag_group 4
tag_group Noticification Engine
State:
- a set of tags that are the members of a given
tag_group
Subjects:
- (in) receives a set of tags which represent a post
- (out) emits a boolean of whether or not a post's tags are a superset of the
tag_group
user Notification Engine
State:
- The associated user
- Subject registry for all child
tag_groupnotification - Subject to emit telegram notifications via if post matches rules
Subjects:
- (in) receives a
Postfrom the image repository API - (in) receives booleans from
tag_groupnotifications - (out) emits a
PostNotificationobject to the telegram notifaction actor
root Notification Engine
The root notification engine manages a dynamic set of actors. New user actors are created
when new users register with the application. user actors are removed when
the user deactivates the application
State:
- A map of
user.id -> user notification subject
Subjects:
- (in) receives a
Postfrom the image repository API - (in) receives application events to start or stop user agents
Development
gleam run # Run the project
gleam test # Run the tests
Environment Variables
The project has several required environment variables:
TG_BOT_TOKEN-> The API token from telegram for the bot accountTG_BOT_SECRET_TOKEN-> A randomly generated secret to prevent request spoofingWEBHOOK_PATH-> The "endpoint" path that TG will send webhook events toSERVER_URL-> The domain that TG will send webhook events to
There are also optional environment variables:
DATABASE_PATH-> The path to the SQLite database. If not set, then the default path will be used