change some models, make get ready to build some UI, etc
This commit is contained in:
parent
1b0912c675
commit
2c35e9c304
4 changed files with 39 additions and 33 deletions
|
@ -105,18 +105,12 @@ func (self *MastoAdapter) mastoUpdateToMessage(status madon.Status) *Message {
|
||||||
parent, _ = self.masto.GetStatus(*status.InReplyToID)
|
parent, _ = self.masto.GetStatus(*status.InReplyToID)
|
||||||
}
|
}
|
||||||
msg := Message{
|
msg := Message{
|
||||||
Protocol: "mastodon",
|
Protocol: "mastodon",
|
||||||
Content: status.Content,
|
Content: status.Content,
|
||||||
Uri: status.URI,
|
Uri: status.URI,
|
||||||
Author: Author{
|
Author: status.Account.Acct,
|
||||||
Id: fmt.Sprintf("%d", status.Account.ID),
|
Created: status.CreatedAt,
|
||||||
Name: status.Account.Username,
|
Visibility: status.Visibility,
|
||||||
// TODO: we can add the fields to the profiledata as well
|
|
||||||
ProfileData: status.Account.Note,
|
|
||||||
ProfileUri: status.Account.URL,
|
|
||||||
ProfilePic: status.Account.Avatar,
|
|
||||||
},
|
|
||||||
Created: status.CreatedAt,
|
|
||||||
}
|
}
|
||||||
if parent != nil {
|
if parent != nil {
|
||||||
msg.ReplyTo = &parent.URI
|
msg.ReplyTo = &parent.URI
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
. "forge.lightcrystal.systems/lightcrystal/underbbs/models"
|
. "forge.lightcrystal.systems/lightcrystal/underbbs/models"
|
||||||
"github.com/yitsushi/go-misskey"
|
"github.com/yitsushi/go-misskey"
|
||||||
|
mkcore "github.com/yitsushi/go-misskey/core"
|
||||||
mkm "github.com/yitsushi/go-misskey/models"
|
mkm "github.com/yitsushi/go-misskey/models"
|
||||||
n "github.com/yitsushi/go-misskey/services/notes"
|
n "github.com/yitsushi/go-misskey/services/notes"
|
||||||
tl "github.com/yitsushi/go-misskey/services/notes/timeline"
|
tl "github.com/yitsushi/go-misskey/services/notes/timeline"
|
||||||
|
@ -175,17 +176,27 @@ func (self *MisskeyAdapter) cacheAndConvert(n mkm.Note) *Message {
|
||||||
if !exists || timestamp.Before(n.CreatedAt) {
|
if !exists || timestamp.Before(n.CreatedAt) {
|
||||||
self.cache[n.ID] = n.CreatedAt
|
self.cache[n.ID] = n.CreatedAt
|
||||||
msg := Message{
|
msg := Message{
|
||||||
Uri: n.URI,
|
Uri: n.URI,
|
||||||
Author: Author{
|
Author: fmt.Sprintf("%s@%s", n.User.Username, mkcore.StringValue(n.User.Host)),
|
||||||
Id: n.User.ID,
|
Protocol: "misskey",
|
||||||
Name: n.User.Name,
|
Adapter: self.nickname,
|
||||||
// ProfileUri: *n.User.URL,
|
Created: n.CreatedAt,
|
||||||
ProfilePic: n.User.AvatarURL,
|
Content: n.Text,
|
||||||
},
|
Attachments: []Attachment{},
|
||||||
Protocol: "misskey",
|
Visibility: n.Visibility,
|
||||||
Adapter: self.nickname,
|
ReplyTo: n.ReplyID,
|
||||||
Created: n.CreatedAt,
|
ReplyCount: int(n.RepliesCount),
|
||||||
Content: n.Text,
|
Replies: []string{},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, f := range n.Files {
|
||||||
|
msg.Attachments = append(msg.Attachments, Attachment{
|
||||||
|
Src: f.URL,
|
||||||
|
ThumbSrc: f.ThumbnailURL,
|
||||||
|
Size: f.Size,
|
||||||
|
Desc: f.Comment,
|
||||||
|
CreatedAt: f.CreatedAt,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return &msg
|
return &msg
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,9 +98,7 @@ func (self *NostrAdapter) nostrEventToMsg(evt *nostr.Event) (Message, error) {
|
||||||
switch evt.Kind {
|
switch evt.Kind {
|
||||||
case nostr.KindTextNote:
|
case nostr.KindTextNote:
|
||||||
m.Uri = evt.ID
|
m.Uri = evt.ID
|
||||||
m.Author = Author{
|
m.Author = evt.PubKey
|
||||||
Id: evt.PubKey,
|
|
||||||
}
|
|
||||||
m.Created = evt.CreatedAt.Time()
|
m.Created = evt.CreatedAt.Time()
|
||||||
m.Content = evt.Content
|
m.Content = evt.Content
|
||||||
return m, nil
|
return m, nil
|
||||||
|
|
|
@ -7,15 +7,17 @@ import (
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
Uri string
|
Uri string
|
||||||
Author Author
|
Author string
|
||||||
Protocol string
|
Protocol string
|
||||||
Adapter string
|
Adapter string
|
||||||
Content string
|
Content string
|
||||||
Attachments []Attachment
|
Attachments []Attachment
|
||||||
ReplyTo *string
|
ReplyTo *string
|
||||||
Replies []*string
|
Replies []string
|
||||||
Mentions []Author
|
ReplyCount int
|
||||||
|
Mentions []string
|
||||||
Created time.Time
|
Created time.Time
|
||||||
|
Visibility string
|
||||||
Aux map[string]string
|
Aux map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,15 +25,16 @@ type Author struct {
|
||||||
Id string
|
Id string
|
||||||
Name string
|
Name string
|
||||||
ProfileData interface{}
|
ProfileData interface{}
|
||||||
Messages []Message
|
|
||||||
ProfileUri string
|
ProfileUri string
|
||||||
ProfilePic string
|
ProfilePic string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Attachment struct {
|
type Attachment struct {
|
||||||
Src string
|
Src string
|
||||||
Data []uint8
|
ThumbSrc string
|
||||||
Desc string
|
Desc string
|
||||||
|
CreatedAt time.Time
|
||||||
|
Size uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type SocketData interface {
|
type SocketData interface {
|
||||||
|
|
Loading…
Reference in a new issue