mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-07 02:08:07 -06:00
updates to models and tags
This commit is contained in:
parent
32629a378d
commit
f91ba5b304
16 changed files with 290 additions and 70 deletions
|
|
@ -60,6 +60,9 @@ type Converter interface {
|
|||
|
||||
// EmojiToMasto converts a gts model emoji into its mastodon (frontend) representation for serialization on the API.
|
||||
EmojiToMasto(e *gtsmodel.Emoji) (mastotypes.Emoji, error)
|
||||
|
||||
// TagToMasto converts a gts model tag into its mastodon (frontend) representation for serialization on the API.
|
||||
TagToMasto(t *gtsmodel.Tag) (mastotypes.Tag, error)
|
||||
}
|
||||
|
||||
type converter struct {
|
||||
|
|
@ -290,7 +293,7 @@ func (c *converter) MentionToMasto(m *gtsmodel.Mention) (mastotypes.Mention, err
|
|||
}
|
||||
|
||||
return mastotypes.Mention{
|
||||
ID: m.ID,
|
||||
ID: target.ID,
|
||||
Username: target.Username,
|
||||
URL: target.URL,
|
||||
Acct: acct,
|
||||
|
|
@ -306,3 +309,12 @@ func (c *converter) EmojiToMasto(e *gtsmodel.Emoji) (mastotypes.Emoji, error) {
|
|||
Category: e.CategoryID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *converter) TagToMasto(t *gtsmodel.Tag) (mastotypes.Tag, error) {
|
||||
tagURL := fmt.Sprintf("%s://%s/tags/%s", c.config.Protocol, c.config.Host, t.Name)
|
||||
|
||||
return mastotypes.Tag{
|
||||
Name: t.Name,
|
||||
URL: tagURL, // we don't serve URLs with collections of tagged statuses (FOR NOW) so this is purely for mastodon compatibility ¯\_(ツ)_/¯
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,4 +20,8 @@ package mastotypes
|
|||
|
||||
// Tag represents a hashtag used within the content of a status. See https://docs.joinmastodon.org/entities/tag/
|
||||
type Tag struct {
|
||||
// The value of the hashtag after the # sign.
|
||||
Name string `json:"name"`
|
||||
// A link to the hashtag on the instance.
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue