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
parent
e0fc3147f7
commit
802109cf31
16
entry.go
16
entry.go
|
@ -75,13 +75,23 @@ func parseRequestBody(r *http.Request) (string, error) {
|
|||
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) {
|
||||
if h, ok := values["h"]; ok && (len(h) != 1 || h[0] != "entry") {
|
||||
return nil, errors.New("only entry type is supported so far")
|
||||
}
|
||||
if _, ok := values["content"]; ok {
|
||||
entry := &Entry{
|
||||
content: values["content"][0],
|
||||
if validEntry(values) {
|
||||
entry := &Entry{}
|
||||
if content, ok := values["content"]; ok {
|
||||
entry.content = content[0]
|
||||
}
|
||||
if name, ok := values["name"]; ok {
|
||||
entry.title = name[0]
|
||||
|
|
Loading…
Reference in New Issue