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

Definitions of reserved extra data namespaces. #151

Closed
eternal-flame-AD opened this issue Mar 10, 2019 · 6 comments
Closed

Definitions of reserved extra data namespaces. #151

eternal-flame-AD opened this issue Mar 10, 2019 · 6 comments

Comments

@eternal-flame-AD
Copy link
Member

We reserved some top-level extra namespaces for gotify official use. The reserved namespaces include gotify android ios web server client.

We need to reach an agreement on how to use these namespaces before we sharting to code detailed implementations.

Firstly,

  • server::* should only have an impact on the gotify server.
  • client::* should only have an impact on the client, and should be platform-independent.
  • web::* should only have an impact on the WebUI.
  • android::* should only have an impact on the official Android client.

I propose we first include resolutions to marking message to be of markdown/html and customized notification patterns.

@eternal-flame-AD
Copy link
Member Author

This is my proposal:
Example:

{
  "client::render": {
    "mode": "text/markdown"
  },
  "web::notification": {
    "mode": "suppress"
  },
  "android::notification": {
    "mode": "enforce",
    "sound": "alarm",
    "vibration": {
      "pattern": [
        [
          16,
          100
        ],
        [
          12,
          200
        ],
        [
          0,
          300
        ],
        [
          12,
          200
        ]
      ]
    }
  }
}

JSON schema:

{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://example.com/root.json",
  "type": "object",
  "title": "The Root Schema",
  "properties": {
    "client::render": {
      "$id": "#/properties/client::render",
      "type": "object",
      "title": "client::render defines how the message should be rendered in UI",
      "default": null,
      "properties": {
        "mode": {
          "$id": "#/properties/client::render/properties/mode",
          "type": "string",
          "enum": [
            "text/plain",
            "text/html",
            "text/markdown"
          ],
          "title": "the content type of message",
          "default": "text/plain",
          "examples": [
            "text/markdown"
          ],
          "pattern": "^(.*)$"
        }
      }
    },
    "web::notification": {
      "$id": "#/properties/web::notification",
      "type": "object",
      "title": "The web::notification Schema",
      "default": null,
      "properties": {
        "mode": {
          "$id": "#/properties/web::notification/properties/mode",
          "type": "string",
          "enum": [
            "suppress",
            "default",
            "enforce"
          ],
          "title": "notification mode",
          "default": "default",
          "examples": [
            "suppress"
          ],
          "pattern": "^(.*)$"
        }
      }
    },
    "android::notification": {
      "$id": "#/properties/android::notification",
      "type": "object",
      "title": "The Android::notification Schema",
      "default": null,
      "properties": {
        "mode": {
          "$id": "#/properties/android::notification/properties/mode",
          "type": "string",
          "enum": [
            "enforce",
            "default",
            "suppress"
          ],
          "title": "notification mode",
          "description": "overrides web::notification",
          "default": "default",
          "examples": [
            "enforce"
          ],
          "pattern": "^(.*)$"
        },
        "sound": {
          "$id": "#/properties/android::notification/properties/sound",
          "type": "string",
          "enum": [
            "alarm",
            "bell",
            "default"
          ],
          "title": "sound",
          "default": "default",
          "pattern": "^(.*)$"
        },
        "vibration": {
          "$id": "#/properties/android::notification/properties/vibration",
          "type": "object",
          "title": "The vibration Schema",
          "description": "inferred by proority when not set",
          "default": null,
          "properties": {
            "pattern": {
              "$id": "#/properties/android::notification/properties/vibration/properties/pattern",
              "type": "array",
              "title": "vibration pattern",
              "description": "The vibration pattern to be used. Inferred by priority when not set.",
              "default": null,
              "minItems": 1,
              "items": {
                "$id": "#/properties/android::notification/properties/vibration/properties/pattern/items",
                "type": "array",
                "title": "vibration pattern items",
                "default": null,
                "items": {
                  "$id": "#/properties/android::notification/properties/vibration/properties/pattern/items/items",
                  "type": "integer",
                  "title": "vibration pattern item",
                  "description": "[intensity. duration]",
                  "default": null,
                  "examples": [
                    16,
                    100
                  ],
                  "minimum": 2.0,
                  "maximum": 2.0
                }
              }
            }
          }
        }
      }
    }
  }
}

@jmattheis
Copy link
Member

Sorry for answering that late. I think we just should add support for markdown it shouldn't break anything. I'm against a client::render setting.

The rest looks good.

Should we enforce the validity of these settings on server side? Otherwise, I'd just document the behavior on gotify/website and implement it on clientside.

@eternal-flame-AD
Copy link
Member Author

I'm against a client::render setting.

Okay, if we do not plan to do anything that alters the render mode in the future we could remove this.

Should we enforce the validity of these settings on server side?

I think this is not needed, at least for now. No matter a server-side validation exists or not, I don't think we can skip that validation on the client side. The benefit of a server-side validation is that we can reject a message if it has malformed extra field, but I think we can display a warning at the bottom of the message in the WebUI and/or android client instead.

@jmattheis
Copy link
Member

jmattheis commented Mar 22, 2019

Okay, we should also versionize the Extras so something like android::notification::v1.

@eternal-flame-AD
Copy link
Member Author

Sounds fine. So the parser will look for extra fields from the highest version to the lowest, and then a default when none is found.

@jmattheis
Copy link
Member

nothing actionable here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants