Better support for Quill's "favorite" request

Quill doesn't send a `content` parameter along with the `like-of` data
when performing a "favorite" request.
kcoram/uplift
Kevin C. Coram 2020-01-04 21:15:06 -05:00
parent e0fc3147f7
commit 802109cf31
Signed by: kevin
GPG Key ID: 0342351B3D61AD35
1 changed files with 13 additions and 3 deletions

View File

@ -75,13 +75,23 @@ func parseRequestBody(r *http.Request) (string, error) {
return string(bodyBytes), nil return string(bodyBytes), nil
} }
func validEntry(values map[string][]string) bool {
if _, ok := values["content"]; ok {
return true
} else if _, ok := values["like-of"]; ok {
return true
}
return false;
}
func createEntryFromValueMap(values map[string][]string) (*Entry, error) { func createEntryFromValueMap(values map[string][]string) (*Entry, error) {
if h, ok := values["h"]; ok && (len(h) != 1 || h[0] != "entry") { if h, ok := values["h"]; ok && (len(h) != 1 || h[0] != "entry") {
return nil, errors.New("only entry type is supported so far") return nil, errors.New("only entry type is supported so far")
} }
if _, ok := values["content"]; ok { if validEntry(values) {
entry := &Entry{ entry := &Entry{}
content: values["content"][0], if content, ok := values["content"]; ok {
entry.content = content[0]
} }
if name, ok := values["name"]; ok { if name, ok := values["name"]; ok {
entry.title = name[0] entry.title = name[0]