diff --git a/adapter/anonAp.go b/adapter/anonAp.go
index 0ee3c8b..ba428c3 100644
--- a/adapter/anonAp.go
+++ b/adapter/anonAp.go
@@ -286,36 +286,24 @@ func (self *anonAPAdapter) Fetch(etype string, ids []string) error {
if err != nil {
return err
}
- fmt.Println(a.Object)
objectData := getBodyJson(res)
object := apObject{}
json.Unmarshal(objectData, &object)
ogMsg := self.toMsg(object)
- if ogMsg != nil {
- self.send(ogMsg)
- }
+ // if we couldn't fetch the original, skip it
+ if ogMsg != nil && ogMsg.Author != "" {
+
t, err := time.Parse(time.RFC3339, a.Published)
if err != nil {
t = time.Now()
}
- vis := strings.Split(a.To, "#")
- if len(vis) > 1 {
- a.To = vis[1]
+ rt := t.UnixMilli()
+ ogMsg.RenoteId = &a.Id
+ ogMsg.Renoter = &a.Actor
+ ogMsg.RenoteTime = &rt
+
+ self.send(ogMsg)
}
- boostMsg := models.Message{
- Datagram: models.Datagram{
- Id: a.Id,
- Uri: a.Id,
- Protocol: self.protocol,
- Adapter: self.nickname,
- Type: "message",
- Created: t.UnixMilli(),
- },
- Author: a.Actor,
- RenoteId: &ogMsg.Id,
- Visibility: a.To,
- }
- self.send(boostMsg)
}
}
// for each item in outbox, check if it's a Create/Update or an Announce
diff --git a/frontend/ts/author-messages-element.ts b/frontend/ts/author-messages-element.ts
index e9dfac3..4d06744 100644
--- a/frontend/ts/author-messages-element.ts
+++ b/frontend/ts/author-messages-element.ts
@@ -49,12 +49,12 @@ export class AuthorMessagesElement extends HTMLElement {
}
let msg = datastore.messages.get(next);
if (msg) {
- const existingIdx = this._messages.findIndex(m=>m.id == msg.id && ((m.edited ?? m.created) < (msg.edited ?? msg.created)));
+ const existingIdx = this._messages.findIndex(m=>(m.renoteId ?? m.id) == (msg.renoteId ?? msg.id) && ((m.edited ?? m.created) < (msg.edited ?? msg.created)));
// first we update the backing data store
if (existingIdx >= 0) {
this._messages[existingIdx] = msg;
- } else if (!this._messages.some(m=>m.id == msg.id)) {
+ } else if (!this._messages.some(m=>(m.renoteId ?? m.id) == (msg.renoteId ?? msg.id))) {
this._messages.push(msg);
}
@@ -64,7 +64,7 @@ export class AuthorMessagesElement extends HTMLElement {
// first pass through the dom, try to update a message if it's there
for (let i = 0; i < ul.childElementCount; i++){
const id = ul.children[i]?.children[0]?.getAttribute("data-target");
- const ogMsg = this._messages.find(m=>m.id == id);
+ const ogMsg = this._messages.find(m=>(m.renoteId ?? m.id) == id);
if (ogMsg && existingIdx >= 0) {
ul.children[i]?.children[0]?.setAttribute("data-latest", id ?? "");
return;
@@ -77,8 +77,8 @@ export class AuthorMessagesElement extends HTMLElement {
// second pass, try to place it in reverse-chronological order
for (let i = 0; i < ul.childElementCount; i++){
const id = ul.children[i]?.children[0]?.getAttribute("data-target");
- const ogMsg = this._messages.find(m=>m.id == id);
- if (ogMsg && ogMsg.created < msg.created) {
+ const ogMsg = this._messages.find(m=>(m.renoteId ?? m.id) == id);
+ if (ogMsg && (ogMsg.renoteTime ?? ogMsg.created) < (msg.renoteTime ?? msg.created)) {
ul.insertBefore(e, ul.children[i])
e.children[0].setAttribute("data-latest", next);
return;
@@ -89,7 +89,6 @@ export class AuthorMessagesElement extends HTMLElement {
ul.append(e);
e.children[0].setAttribute("data-latest", next);
}
- console.log(JSON.stringify(this._messages));
}
}
}
diff --git a/frontend/ts/message-element.ts b/frontend/ts/message-element.ts
index 9e9a84c..4650173 100644
--- a/frontend/ts/message-element.ts
+++ b/frontend/ts/message-element.ts
@@ -56,7 +56,12 @@ export class MessageElement extends HTMLElement {
const content = this.querySelector(".message_content");
const attachments = this.querySelector(".message_attachments");
if (metadata) {
- metadata.innerHTML = `${this._message.author}${new Date(this._message.created)}${this._message.visibility}${this._message.protocol}`
+ if (this._message.renoteId) {
+ metadata.innerHTML = `${this._message.renoter}${new Date(this._message.renoteTime ?? 0)}`
+ } else {
+ metadata.innerHTML = "";
+ }
+ metadata.innerHTML += `${this._message.author}${new Date(this._message.created)}${this._message.visibility}${this._message.protocol}`
}
if (content) {
content.innerHTML = this._message.content;
diff --git a/frontend/ts/message.ts b/frontend/ts/message.ts
index 84de9a0..a25c111 100644
--- a/frontend/ts/message.ts
+++ b/frontend/ts/message.ts
@@ -13,6 +13,8 @@ export class Message {
public edited: number | null = null;
public visibility: string = "public";
public renoteId: string | null = null;
+ public renoter: string | null = null;
+ public renoteTime: Date | null = null;
}
export class Author {
diff --git a/frontend/ts/websocket.ts b/frontend/ts/websocket.ts
index a1a4208..5c51979 100644
--- a/frontend/ts/websocket.ts
+++ b/frontend/ts/websocket.ts
@@ -48,7 +48,7 @@ export class DatagramSocket {
// typeswitch on the incoming data type and fill the memory
switch (data.type) {
case "message":
- store.messages.set(data.id, data);
+ store.messages.set(data.renoteId ?? data.id, data);
break;
case "author":
store.profileCache.set(data.id, data);
@@ -67,6 +67,13 @@ export class DatagramSocket {
byAuthorTargets.forEach(t=>{
t.setAttribute("data-latest", data.id);
});
+ if (data.renoter) {
+ let byAuthorTargetsForBoosts = document.querySelectorAll(`underbbs-author-messages[data-adapter="${data.adapter}"][data-target="${data.renoter}"]`);
+ byAuthorTargetsForBoosts.forEach(t=>{
+ console.log("setting renote id on data-latest")
+ t.setAttribute("data-latest", data.renoteId);
+ });
+ }
}
}
diff --git a/models/msg.go b/models/msg.go
index 7cd893e..e6efd3c 100644
--- a/models/msg.go
+++ b/models/msg.go
@@ -26,6 +26,8 @@ type Message struct {
Mentions []string `json:"mentions"`
Visibility string `json:"visibility"`
RenoteId *string `json:"renoteId,omitempty"`
+ Renoter *string `json:"renoter,omitempty"`
+ RenoteTime *int64 `json:"renoteTime,omitempty"`
}
type Author struct {