diff --git a/_embed/templates/user-inbox/following-list.html b/_embed/templates/user-inbox/following-list.html index 79207306..f61e079b 100644 --- a/_embed/templates/user-inbox/following-list.html +++ b/_embed/templates/user-inbox/following-list.html @@ -33,10 +33,10 @@ {{ icon .Icon }} {{.Method}} {{ .LastPolled | tinyDate }} - {{- else if eq "LOADING" .Status -}} - {{.Status}} - {{- else -}} + {{- else if eq "ERROR" .Status -}} {{.Status}} + {{- else -}} + {{.Status}} {{- end -}} diff --git a/service/following_threads.go b/service/following_threads.go index a3a12252..95832803 100644 --- a/service/following_threads.go +++ b/service/following_threads.go @@ -16,6 +16,12 @@ func (service *Following) SaveMessage(following *model.Following, document strea document, originType = getPrimaryPost(document, originType) } + // If document does not include enough data to create a message, then skip it. + if notAdequate(document) { + derp.Report(derp.NewInternalError("service.Following.SaveMessage", "Skipping inadequate document", document.Value())) + return nil + } + // Convert the document into a message (and traverse responses if necessary) message := getMessage(following, document, originType) @@ -84,6 +90,9 @@ func (service *Following) saveUniqueMessage(message model.Message) error { // TODO: LOW: In the future, the "context" value may be useful in traversing this list. func getPrimaryPost(document streams.Document, originType string) (streams.Document, string) { + // Unwrap "activity" documents + document = document.UnwrapActivity() + if inReplyTo := document.InReplyTo(); inReplyTo.NotNil() { // Change origin type from PRIMARY to REPLY without affecting @@ -101,6 +110,29 @@ func getPrimaryPost(document streams.Document, originType string) (streams.Docum return document, originType } +// isAdequate returns TRUE if the document contains enough data to create an adequiae message. +func isAdequate(document streams.Document) bool { + + if document.Name() != "" { + return true + } + + if document.Summary() != "" { + return true + } + + if document.Content() != "" { + return true + } + + return false +} + +// notAdequate returns TRUE if the document DOES NOT contain enough data to create an adequiae message. +func notAdequate(document streams.Document) bool { + return !isAdequate(document) +} + // getMessage returns a Message object based on the provided arguments. func getMessage(following *model.Following, document streams.Document, originType string) model.Message {