Skip to content

[Feature Request] API Hook for Date/Time Interval Retrieval of Messages #889

@cxtal

Description

@cxtal

Hi!

I am one of the developers working on Winify, a graphical UI client for Windows and one of the features that we implement is the retrieval of past notifications between a certain time-interval.

The problem is that there is no direct API hook to do that directly via Gotify. What we do instead is use the /application/{Id}/message REST path and recursively retrieve all the messages by using the Gotify pagination. After that, we sort all the messages and only then apply the user-requested date-range filter. I am unaware of any correlation between the since parameter and the actual date when the notification was sent, is there a correlation?

As you can imagine, if the Gotify server has been running for a while, retrieving all the messages or going through all the messages just to find a date-range is a miserable experience for the user, let alone the fact that loading the messages just means more a/deallocations producing memory spikes unnecessarily (this is something that we can optimize on our end, but not the time it takes to retrieve them all).

Would it be possible for you to add a hook for the API that would allow the retrieval of messages from a given application by applying a date-time filter? Right now there is:

/application/{Id}/message

so maybe something like:

/application/{Id}/message/{date}

or part of the rest of the other parameters

/application/{Id}/message?date=...

By implementing this, time to the amount of linear time complexity O(a * m) where a would be the number of applications and m would be the number of messages could just be reduced to O(a). In case the application ID is known, which in many cases it is because the option in our software is usually provided from the UI to select an application, then the whole O(a *m) is reduced to just a single operation O(1) which is an amazing performance boost at no cost.

I have not looked into Gotify myself, so I do not know the internals and I haven't dabbled in Go yet but the actual date when a notification arrives is already recorded by Gotify internally as part of the message structure such that it should not be too costly. We also filter by other criteria when searching, but that criteria is not to be found in your Gotify message structure so that would be more difficult.

Feature request #376 seems somewhat related given that a notification typically has a very short lifespan because it is supposed to notify the user what happened "now" contrasted to say a database that can hold long-term data. However, at the same time, browsing through age-old notifications like "outdoor lights went on" that took place a month ago seems irrelevant. Pagination is great for an UI when a user can click inputs and browse pages of data arranged such that not too many appear at the same time, but when you are accessing Gotify programmatically like from Winify, pagination can take a huge time and makes a bunch of useless requests.

Could you please implement this REST API path?

Thank you!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions