diff --git a/contrib/backends/srndv2/src/srnd/frontend_http.go b/contrib/backends/srndv2/src/srnd/frontend_http.go
index b9a4a7e..5ef20f7 100644
--- a/contrib/backends/srndv2/src/srnd/frontend_http.go
+++ b/contrib/backends/srndv2/src/srnd/frontend_http.go
@@ -1062,27 +1062,30 @@ func (self httpFrontend) handle_authed_api(wr http.ResponseWriter, r *http.Reque
func (self *httpFrontend) handle_api_find(wr http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
h := q.Get("hash")
+ msgid := q.Get("id")
if len(h) > 0 {
- msgid := q.Get("id")
- if len(h) > 0 {
- e, err := self.daemon.database.GetMessageIDByHash(h)
- if err == nil {
- msgid = e.MessageID()
- }
+ e, err := self.daemon.database.GetMessageIDByHash(h)
+ if err == nil {
+ msgid = e.MessageID()
}
- if len(msgid) > 0 {
- // found it (probaly)
- model := self.daemon.database.GetPostModel(self.prefix, msgid)
- if model == nil {
- // no model
+ }
+
+ if !ValidMessageID(msgid) {
+ msgid = ""
+ }
+
+ if len(msgid) > 0 {
+ self.daemon.store.GetMessage(msgid, func(nntp NNTPMessage) {
+ if nntp == nil {
wr.WriteHeader(404)
- } else {
- // we found it
- wr.Header().Add("Content-Type", "text/json; encoding=UTF-8")
- json.NewEncoder(wr).Encode([]PostModel{model})
+ return
}
- return
- }
+ model := PostModelFromMessage(self.prefix, nntp)
+ // we found it
+ wr.Header().Add("Content-Type", "text/json; encoding=UTF-8")
+ json.NewEncoder(wr).Encode([]PostModel{model})
+ })
+ return
}
s := q.Get("text")
g := q.Get("group")
diff --git a/contrib/backends/srndv2/src/srnd/model_mem.go b/contrib/backends/srndv2/src/srnd/model_mem.go
index b31b4d5..d4323d9 100644
--- a/contrib/backends/srndv2/src/srnd/model_mem.go
+++ b/contrib/backends/srndv2/src/srnd/model_mem.go
@@ -295,6 +295,7 @@ type post struct {
Type string
nntp_id int
FrontendPublicKey string
+ ReferencedURI string
}
func (p *post) IsCtl() bool {
@@ -411,7 +412,7 @@ func (self *attachment) Filename() string {
return self.Name
}
-func PostModelFromMessage(parent, prefix string, nntp NNTPMessage) PostModel {
+func PostModelFromMessage(prefix string, nntp NNTPMessage) PostModel {
p := new(post)
p.PostName = nntp.Name()
p.PostSubject = nntp.Subject()
@@ -422,10 +423,11 @@ func PostModelFromMessage(parent, prefix string, nntp NNTPMessage) PostModel {
p.Posted = nntp.Posted()
p.op = nntp.OP()
p.prefix = prefix
- p.Parent = parent
+ p.Parent = nntp.Reference()
p.addr = nntp.Addr()
p.sage = nntp.Sage()
p.Key = nntp.Pubkey()
+ p.ReferencedURI = nntp.Headers().Get("X-Referenced-Uri", "")
p.FrontendPublicKey = nntp.FrontendPubkey()
for _, att := range nntp.Attachments() {
p.Files = append(p.Files, att.ToModel(prefix))
@@ -627,6 +629,7 @@ func (self *post) Truncate() PostModel {
// TODO: copy?
Files: self.Files,
FrontendPublicKey: self.FrontendPublicKey,
+ ReferencedURI: self.ReferencedURI,
}
}
diff --git a/contrib/templates/placebo/post.mustache b/contrib/templates/placebo/post.mustache
index fa6066b..1145e59 100644
--- a/contrib/templates/placebo/post.mustache
+++ b/contrib/templates/placebo/post.mustache
@@ -42,5 +42,27 @@
+ {{#post.OP}}
+
+ {{/post.OP}}
+
diff --git a/contrib/templates/placebo/thread.mustache b/contrib/templates/placebo/thread.mustache
index 5b5329e..5f4d118 100644
--- a/contrib/templates/placebo/thread.mustache
+++ b/contrib/templates/placebo/thread.mustache
@@ -57,10 +57,10 @@
{{^thread.BumpLock}}