Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically creating notifications #4

Open
Dexagod opened this issue Dec 4, 2020 · 0 comments
Open

Dynamically creating notifications #4

Dexagod opened this issue Dec 4, 2020 · 0 comments

Comments

@Dexagod
Copy link

Dexagod commented Dec 4, 2020

Dynamically creating notifications

External dependency

The creation of notifications should eventually be handled using an external library, as a notification agent should not be responsible for creating the notification itself.
However, this is an important part of the notification lifecycle, as creation of notifications should be easy and straightforward for developers.

Different approaches are possible here.

Templating

A first approach to dynamically create notifications using templating tools.
Templating tools enable the quick and easy creation of RDF notifications, by only requiring a mapping to be provided for the template.
Templates also can help developers that are not familiar with RDF to create notifications that are in a correct RDF format.

Direct rdf injection

A second approach that can be used is to inject rdf data directly into the notification body.
This approach gives more freedom to adding data to an existing notification.
This solution works regardless of the RDF format of the notification, or the injected data.
However it may be more difficult for developers that are not familiar with RDF, and it also is less straightforward to use on te CLI.
Also in the case data is to be added to an object that does not have an identifier, this approach is not evident.

This approach is used to add the sender, receiver, cc and bcc metadata to the notification body. However here we run into this last issue that the notification root does not have an identifier, for which an issue has been opened here.

Approach

Currently, the approach to creating new notifications is done with templating.
The templating approach uses a JSON templating library.
This JSON templating library is used to create JSONLD templates, for which a mapping can easily be provided in the CLI and JavaScript interfaces.

This is solution that will probably be more familiar to developers working with JSON data.
It can also easily be used in the command line, as only minimal mapping has to be provided.

Template file:
template.jsonld

{
  "@context": {"ex": "https://example.com"},
  "summary": "Automated location update of smartphone to pod environment",
  "type": "Update",
  "actor": {
    "@id": "ex:Alice",
    "type": "Person",
    "name": "Alice"
  },
  "location": {    
    "type": "Place",
    "longitude": "{{longitude}}",
    "latitude": "{{latitude}}",
    "altitude": "{{altitude}}",
    "units": "m"
  },
  "updated": "{{timestamp}}"
}
 

CLI send notification

// -c <config>    : config file
// -f             : file flag
// -t             : template fla
// send <receiver> [mapping...]
ldn-agent -c ./config.json send -ft https://receiver.ex#me ./template.jsonld longitude:X latitude:Y altitude:Z updated:$(date)

JS send notification

cont agent = new LDNAgent(config)
agent.send({
  template: ./template.jsonld, 
  mapping: {
    longitude: X,
    latitude: Y,
    altitude: Z,
    updated: new Date()
  }
})

Concrete questions:

  • Is this JSONLD templating approach adequate for now?
  • Is further RDF injection desirable (currently used for sender, receiver ,... metadata)
  • Should other avenues be explored in this?
  • Should this be moved to an external library, or as a submodule of the agent?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant