gotify / server

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
https://gotify.net
Other
10.43k stars 593 forks source link

Update Message #631

Closed ZinedineR closed 5 months ago

ZinedineR commented 5 months ago

Currently I'm writing a create message with extract value of "is_read", since my app needs to know if a message has been read or not. Perhaps add a feature to update message? it would be helpful if there's feature to update the value of message

func (b *BaseHTTPHandler) GotifyCreateMessage(token, subject, body string) (
    *domain.GotifyCreateMessageResponse, int, error,
) {
    var response domain.GotifyCreateMessageResponse
    urlPath := os.Getenv("GOTIFY_URL") + "/message?token=" + token

    extras := map[string]interface{}{
        "is_read": false,
    }
    request := map[string]interface{}{
        "extras":   extras,
        "title":    subject,
        "message":  body,
        "priority": 2,
    }

    params := map[string]string{
        "Content-Type": "application/json",
        "accept":       "application/json",
    }

    statusCode, err := b.HttpClient.PostJSON(urlPath, request, params, &response)
    if err != nil {
        return &response, statusCode, err
    }
    return &response, statusCode, nil
}
jmattheis commented 5 months ago

Duplicate: https://github.com/gotify/server/issues/302

ZinedineR commented 5 months ago

it would not be the best case to do this, since your createmessage the default date is time.Now() suppose it would mess with the ordered list (if the old message deleted and creating a new one)

but okay, for right now I would use my own "date" variable inside extras. I just hope this would be implemented since what you need is give the function in the database and router.