notify.pl -- SWISH notifications
This module keeps track of which users wish to track which notifications
and sending the notifications to the user. If the target user is online
we will notify using an avatar. Otherwise we send an email.
A user has the following options to control notifications:
- Per (gitty) file
- Notify update
- Notify chat
- By profile
- Notify by E-mail: never/immediate/daily
- redis_docid_key(+DocId, -Server, -Key) is semidet[private]
- redis_queue_key(Server, -Key) is semidet[private]
- Get the Redis server and key for specific requests. The Redis DB is
organised as follows:
- Prefix:notify:docid:Docid
- A hash mapping profile ids onto a Prolog list of flags
- Prefix:notify:queue
- A list of Prolog terms holding queued pending
email notifications.
- queue_event(+Profile, +DocID, +Action) is det[private]
- queue_event(+Profile, +DocID, +Action, +Status) is det[private]
- Queue an email notification for Profile, described by Action. We
simply append these events as Prolog terms to a file.
- Arguments:
-
Status | - is one of new or retry(Count,Status) , where Count is
the number of left attempts and Status is the last status. |
- send_queued_mails is det[private]
- Send possible queued emails.
- start_mail_scheduler[private]
- Start a thread that schedules queued mail handling.
- mail_main[private]
- Infinite loop that schedules sending queued messages.
- following(+DocID, ?ProfileID, ?Flags) is nondet[private]
- follow(+DocID, +ProfileID, +Flags) is det
- Assert that DocID is being followed by ProfileID using Flags.
- notify(+DocID, +Action) is det
- Action has been executed on DocID. Notify all interested users.
Actions that may be notified:
- updated(Commit)
- Gitty file was updated
- deleted(Commit)
- Gitty file was deleted
- forked(OldCommit, Commit)
- Gitty file was forked
- created(Commit)
- A new gitty file was created
- chat(Message)
- A chat message was sent. Message is the JSON content as a dict.
Message contains a
docid
key.
- notify_user(+Profile, +DocID, +Action, +Options)[private]
- Notify the user belonging to Profile about Action, which is related
to document DocID.
- event_generator(+Event, -ProfileID) is semidet[private]
- True when ProfileID refers to the user that initiated Event.
- notify_in_chat(+DocID, +Action)[private]
- action_user(+Action, -User) is det[private]
- Describe a user for chat purposes. Such a user is identified by the
profile_id
, name
and/or avatar
.
- message(+ProfileID, +DocID, +Action)//[private]
- follow_file_options(+Request)[private]
- Edit the file following options for the current user.
- save_follow_file(+Request)[private]
- Save the follow file options