2021-04-19 17:42:19 +00:00
|
|
|
/*
|
|
|
|
GoToSocial
|
|
|
|
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
package typeutils
|
2021-04-19 17:42:19 +00:00
|
|
|
|
|
|
|
import (
|
2021-08-25 13:34:33 +00:00
|
|
|
"context"
|
2021-04-19 17:42:19 +00:00
|
|
|
"fmt"
|
2021-05-17 17:06:58 +00:00
|
|
|
"strings"
|
2021-04-19 17:42:19 +00:00
|
|
|
"time"
|
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/api/model"
|
2021-04-19 17:42:19 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/db"
|
2021-05-08 12:25:55 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
2021-04-19 17:42:19 +00:00
|
|
|
)
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) AccountToMastoSensitive(ctx context.Context, a *gtsmodel.Account) (*model.Account, error) {
|
2021-04-19 17:42:19 +00:00
|
|
|
// we can build this sensitive account easily by first getting the public account....
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoAccount, err := c.AccountToMastoPublic(ctx, a)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// then adding the Source object to it...
|
|
|
|
|
|
|
|
// check pending follow requests aimed at this account
|
2021-08-25 13:34:33 +00:00
|
|
|
frs, err := c.db.GetAccountFollowRequests(ctx, a.ID)
|
2021-08-20 10:26:56 +00:00
|
|
|
if err != nil {
|
|
|
|
if err != db.ErrNoEntries {
|
2021-04-19 17:42:19 +00:00
|
|
|
return nil, fmt.Errorf("error getting follow requests: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var frc int
|
2021-08-20 10:26:56 +00:00
|
|
|
if frs != nil {
|
|
|
|
frc = len(frs)
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
mastoAccount.Source = &model.Source{
|
2021-08-25 13:34:33 +00:00
|
|
|
Privacy: c.VisToMasto(ctx, a.Privacy),
|
2021-04-19 17:42:19 +00:00
|
|
|
Sensitive: a.Sensitive,
|
|
|
|
Language: a.Language,
|
|
|
|
Note: a.Note,
|
|
|
|
Fields: mastoAccount.Fields,
|
|
|
|
FollowRequestsCount: frc,
|
|
|
|
}
|
|
|
|
|
|
|
|
return mastoAccount, nil
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) AccountToMastoPublic(ctx context.Context, a *gtsmodel.Account) (*model.Account, error) {
|
|
|
|
if a == nil {
|
|
|
|
return nil, fmt.Errorf("given account was nil")
|
|
|
|
}
|
|
|
|
|
2021-08-20 10:26:56 +00:00
|
|
|
// count followers
|
2021-08-25 13:34:33 +00:00
|
|
|
followersCount, err := c.db.CountAccountFollowedBy(ctx, a.ID, false)
|
2021-08-20 10:26:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error counting followers: %s", err)
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// count following
|
2021-08-25 13:34:33 +00:00
|
|
|
followingCount, err := c.db.CountAccountFollows(ctx, a.ID, false)
|
2021-08-20 10:26:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error counting following: %s", err)
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// count statuses
|
2021-08-25 13:34:33 +00:00
|
|
|
statusesCount, err := c.db.CountAccountStatuses(ctx, a.ID)
|
2021-05-17 17:06:58 +00:00
|
|
|
if err != nil {
|
2021-08-20 10:26:56 +00:00
|
|
|
return nil, fmt.Errorf("error counting statuses: %s", err)
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check when the last status was
|
|
|
|
var lastStatusAt string
|
2021-08-25 13:34:33 +00:00
|
|
|
lastPosted, err := c.db.GetAccountLastPosted(ctx, a.ID)
|
2021-08-20 10:26:56 +00:00
|
|
|
if err == nil && !lastPosted.IsZero() {
|
|
|
|
lastStatusAt = lastPosted.Format(time.RFC3339)
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// build the avatar and header URLs
|
2021-08-20 10:26:56 +00:00
|
|
|
var aviURL string
|
|
|
|
var aviURLStatic string
|
|
|
|
if a.AvatarMediaAttachmentID != "" {
|
|
|
|
// make sure avi is pinned to this account
|
|
|
|
if a.AvatarMediaAttachment == nil {
|
2021-08-25 13:34:33 +00:00
|
|
|
avi, err := c.db.GetAttachmentByID(ctx, a.AvatarMediaAttachmentID)
|
2021-08-20 10:26:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error retrieving avatar: %s", err)
|
|
|
|
}
|
|
|
|
a.AvatarMediaAttachment = avi
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
2021-08-20 10:26:56 +00:00
|
|
|
aviURL = a.AvatarMediaAttachment.URL
|
|
|
|
aviURLStatic = a.AvatarMediaAttachment.Thumbnail.URL
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
|
2021-08-20 10:26:56 +00:00
|
|
|
var headerURL string
|
|
|
|
var headerURLStatic string
|
|
|
|
if a.HeaderMediaAttachmentID != "" {
|
|
|
|
// make sure header is pinned to this account
|
|
|
|
if a.HeaderMediaAttachment == nil {
|
2021-08-25 13:34:33 +00:00
|
|
|
avi, err := c.db.GetAttachmentByID(ctx, a.HeaderMediaAttachmentID)
|
2021-08-20 10:26:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error retrieving avatar: %s", err)
|
|
|
|
}
|
|
|
|
a.HeaderMediaAttachment = avi
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
2021-08-20 10:26:56 +00:00
|
|
|
headerURL = a.HeaderMediaAttachment.URL
|
|
|
|
headerURLStatic = a.HeaderMediaAttachment.Thumbnail.URL
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// get the fields set on this account
|
2021-05-08 12:25:55 +00:00
|
|
|
fields := []model.Field{}
|
2021-04-19 17:42:19 +00:00
|
|
|
for _, f := range a.Fields {
|
2021-05-08 12:25:55 +00:00
|
|
|
mField := model.Field{
|
2021-04-19 17:42:19 +00:00
|
|
|
Name: f.Name,
|
|
|
|
Value: f.Value,
|
|
|
|
}
|
|
|
|
if !f.VerifiedAt.IsZero() {
|
|
|
|
mField.VerifiedAt = f.VerifiedAt.Format(time.RFC3339)
|
|
|
|
}
|
|
|
|
fields = append(fields, mField)
|
|
|
|
}
|
|
|
|
|
2021-05-27 14:06:24 +00:00
|
|
|
emojis := []model.Emoji{}
|
|
|
|
// TODO: account emojis
|
|
|
|
|
2021-04-19 17:42:19 +00:00
|
|
|
var acct string
|
|
|
|
if a.Domain != "" {
|
|
|
|
// this is a remote user
|
|
|
|
acct = fmt.Sprintf("%s@%s", a.Username, a.Domain)
|
|
|
|
} else {
|
|
|
|
// this is a local user
|
|
|
|
acct = a.Username
|
|
|
|
}
|
|
|
|
|
2021-07-11 14:22:21 +00:00
|
|
|
var suspended bool
|
|
|
|
if !a.SuspendedAt.IsZero() {
|
|
|
|
suspended = true
|
|
|
|
}
|
|
|
|
|
2021-08-20 10:26:56 +00:00
|
|
|
accountFrontend := &model.Account{
|
2021-04-19 17:42:19 +00:00
|
|
|
ID: a.ID,
|
|
|
|
Username: a.Username,
|
|
|
|
Acct: acct,
|
|
|
|
DisplayName: a.DisplayName,
|
|
|
|
Locked: a.Locked,
|
|
|
|
Bot: a.Bot,
|
|
|
|
CreatedAt: a.CreatedAt.Format(time.RFC3339),
|
|
|
|
Note: a.Note,
|
|
|
|
URL: a.URL,
|
|
|
|
Avatar: aviURL,
|
|
|
|
AvatarStatic: aviURLStatic,
|
|
|
|
Header: headerURL,
|
|
|
|
HeaderStatic: headerURLStatic,
|
|
|
|
FollowersCount: followersCount,
|
|
|
|
FollowingCount: followingCount,
|
|
|
|
StatusesCount: statusesCount,
|
|
|
|
LastStatusAt: lastStatusAt,
|
2021-05-27 14:06:24 +00:00
|
|
|
Emojis: emojis, // TODO: implement this
|
2021-04-19 17:42:19 +00:00
|
|
|
Fields: fields,
|
2021-07-11 14:22:21 +00:00
|
|
|
Suspended: suspended,
|
2021-08-20 10:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return accountFrontend, nil
|
2021-07-11 14:22:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) AccountToMastoBlocked(ctx context.Context, a *gtsmodel.Account) (*model.Account, error) {
|
2021-07-11 14:22:21 +00:00
|
|
|
var acct string
|
|
|
|
if a.Domain != "" {
|
|
|
|
// this is a remote user
|
|
|
|
acct = fmt.Sprintf("%s@%s", a.Username, a.Domain)
|
|
|
|
} else {
|
|
|
|
// this is a local user
|
|
|
|
acct = a.Username
|
|
|
|
}
|
|
|
|
|
|
|
|
var suspended bool
|
|
|
|
if !a.SuspendedAt.IsZero() {
|
|
|
|
suspended = true
|
|
|
|
}
|
|
|
|
|
|
|
|
return &model.Account{
|
|
|
|
ID: a.ID,
|
|
|
|
Username: a.Username,
|
|
|
|
Acct: acct,
|
|
|
|
DisplayName: a.DisplayName,
|
|
|
|
Bot: a.Bot,
|
|
|
|
CreatedAt: a.CreatedAt.Format(time.RFC3339),
|
|
|
|
URL: a.URL,
|
|
|
|
Suspended: suspended,
|
2021-04-19 17:42:19 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) AppToMastoSensitive(ctx context.Context, a *gtsmodel.Application) (*model.Application, error) {
|
2021-05-08 12:25:55 +00:00
|
|
|
return &model.Application{
|
2021-04-19 17:42:19 +00:00
|
|
|
ID: a.ID,
|
|
|
|
Name: a.Name,
|
|
|
|
Website: a.Website,
|
|
|
|
RedirectURI: a.RedirectURI,
|
|
|
|
ClientID: a.ClientID,
|
|
|
|
ClientSecret: a.ClientSecret,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) AppToMastoPublic(ctx context.Context, a *gtsmodel.Application) (*model.Application, error) {
|
2021-05-08 12:25:55 +00:00
|
|
|
return &model.Application{
|
2021-04-19 17:42:19 +00:00
|
|
|
Name: a.Name,
|
|
|
|
Website: a.Website,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) AttachmentToMasto(ctx context.Context, a *gtsmodel.MediaAttachment) (model.Attachment, error) {
|
2021-05-08 12:25:55 +00:00
|
|
|
return model.Attachment{
|
2021-04-19 17:42:19 +00:00
|
|
|
ID: a.ID,
|
2021-05-17 17:06:58 +00:00
|
|
|
Type: strings.ToLower(string(a.Type)),
|
2021-04-19 17:42:19 +00:00
|
|
|
URL: a.URL,
|
|
|
|
PreviewURL: a.Thumbnail.URL,
|
|
|
|
RemoteURL: a.RemoteURL,
|
|
|
|
PreviewRemoteURL: a.Thumbnail.RemoteURL,
|
2021-05-08 12:25:55 +00:00
|
|
|
Meta: model.MediaMeta{
|
|
|
|
Original: model.MediaDimensions{
|
2021-04-19 17:42:19 +00:00
|
|
|
Width: a.FileMeta.Original.Width,
|
|
|
|
Height: a.FileMeta.Original.Height,
|
|
|
|
Size: fmt.Sprintf("%dx%d", a.FileMeta.Original.Width, a.FileMeta.Original.Height),
|
|
|
|
Aspect: float32(a.FileMeta.Original.Aspect),
|
|
|
|
},
|
2021-05-08 12:25:55 +00:00
|
|
|
Small: model.MediaDimensions{
|
2021-04-19 17:42:19 +00:00
|
|
|
Width: a.FileMeta.Small.Width,
|
|
|
|
Height: a.FileMeta.Small.Height,
|
|
|
|
Size: fmt.Sprintf("%dx%d", a.FileMeta.Small.Width, a.FileMeta.Small.Height),
|
|
|
|
Aspect: float32(a.FileMeta.Small.Aspect),
|
|
|
|
},
|
2021-05-08 12:25:55 +00:00
|
|
|
Focus: model.MediaFocus{
|
2021-04-19 17:42:19 +00:00
|
|
|
X: a.FileMeta.Focus.X,
|
|
|
|
Y: a.FileMeta.Focus.Y,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Description: a.Description,
|
|
|
|
Blurhash: a.Blurhash,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) MentionToMasto(ctx context.Context, m *gtsmodel.Mention) (model.Mention, error) {
|
|
|
|
if m.TargetAccount == nil {
|
|
|
|
targetAccount, err := c.db.GetAccountByID(ctx, m.TargetAccountID)
|
|
|
|
if err != nil {
|
|
|
|
return model.Mention{}, err
|
|
|
|
}
|
|
|
|
m.TargetAccount = targetAccount
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var local bool
|
2021-08-25 13:34:33 +00:00
|
|
|
if m.TargetAccount.Domain == "" {
|
2021-04-19 17:42:19 +00:00
|
|
|
local = true
|
|
|
|
}
|
|
|
|
|
|
|
|
var acct string
|
|
|
|
if local {
|
2021-08-25 13:34:33 +00:00
|
|
|
acct = m.TargetAccount.Username
|
2021-04-19 17:42:19 +00:00
|
|
|
} else {
|
2021-08-25 13:34:33 +00:00
|
|
|
acct = fmt.Sprintf("%s@%s", m.TargetAccount.Username, m.TargetAccount.Domain)
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
return model.Mention{
|
2021-08-25 13:34:33 +00:00
|
|
|
ID: m.TargetAccount.ID,
|
|
|
|
Username: m.TargetAccount.Username,
|
|
|
|
URL: m.TargetAccount.URL,
|
2021-04-19 17:42:19 +00:00
|
|
|
Acct: acct,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) EmojiToMasto(ctx context.Context, e *gtsmodel.Emoji) (model.Emoji, error) {
|
2021-05-08 12:25:55 +00:00
|
|
|
return model.Emoji{
|
2021-04-19 17:42:19 +00:00
|
|
|
Shortcode: e.Shortcode,
|
|
|
|
URL: e.ImageURL,
|
|
|
|
StaticURL: e.ImageStaticURL,
|
|
|
|
VisibleInPicker: e.VisibleInPicker,
|
|
|
|
Category: e.CategoryID,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) TagToMasto(ctx context.Context, t *gtsmodel.Tag) (model.Tag, error) {
|
2021-05-08 12:25:55 +00:00
|
|
|
return model.Tag{
|
2021-04-19 17:42:19 +00:00
|
|
|
Name: t.Name,
|
2021-08-25 13:34:33 +00:00
|
|
|
URL: t.URL,
|
2021-04-19 17:42:19 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) StatusToMasto(ctx context.Context, s *gtsmodel.Status, requestingAccount *gtsmodel.Account) (*model.Status, error) {
|
2021-08-29 10:03:08 +00:00
|
|
|
l := c.log
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
repliesCount, err := c.db.CountStatusReplies(ctx, s)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error counting replies: %s", err)
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
reblogsCount, err := c.db.CountStatusReblogs(ctx, s)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error counting reblogs: %s", err)
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
favesCount, err := c.db.CountStatusFaves(ctx, s)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error counting faves: %s", err)
|
|
|
|
}
|
|
|
|
|
2021-05-08 13:16:24 +00:00
|
|
|
var mastoRebloggedStatus *model.Status
|
|
|
|
if s.BoostOfID != "" {
|
|
|
|
// the boosted status might have been set on this struct already so check first before doing db calls
|
2021-08-20 10:26:56 +00:00
|
|
|
if s.BoostOf == nil {
|
2021-05-08 13:16:24 +00:00
|
|
|
// it's not set so fetch it from the db
|
2021-08-25 13:34:33 +00:00
|
|
|
bs, err := c.db.GetStatusByID(ctx, s.BoostOfID)
|
|
|
|
if err != nil {
|
2021-05-08 13:16:24 +00:00
|
|
|
return nil, fmt.Errorf("error getting boosted status with id %s: %s", s.BoostOfID, err)
|
|
|
|
}
|
2021-08-20 10:26:56 +00:00
|
|
|
s.BoostOf = bs
|
2021-05-08 13:16:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// the boosted account might have been set on this struct already or passed as a param so check first before doing db calls
|
2021-08-20 10:26:56 +00:00
|
|
|
if s.BoostOfAccount == nil {
|
2021-05-08 13:16:24 +00:00
|
|
|
// it's not set so fetch it from the db
|
2021-08-25 13:34:33 +00:00
|
|
|
ba, err := c.db.GetAccountByID(ctx, s.BoostOf.AccountID)
|
|
|
|
if err != nil {
|
2021-08-20 10:26:56 +00:00
|
|
|
return nil, fmt.Errorf("error getting boosted account %s from status with id %s: %s", s.BoostOf.AccountID, s.BoostOfID, err)
|
2021-05-08 13:16:24 +00:00
|
|
|
}
|
2021-08-20 10:26:56 +00:00
|
|
|
s.BoostOfAccount = ba
|
|
|
|
s.BoostOf.Account = ba
|
2021-05-08 13:16:24 +00:00
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoRebloggedStatus, err = c.StatusToMasto(ctx, s.BoostOf, requestingAccount)
|
2021-06-17 16:02:33 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error converting boosted status to mastotype: %s", err)
|
2021-05-08 13:16:24 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-19 17:42:19 +00:00
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
var mastoApplication *model.Application
|
2021-04-19 17:42:19 +00:00
|
|
|
if s.CreatedWithApplicationID != "" {
|
|
|
|
gtsApplication := >smodel.Application{}
|
2021-08-25 13:34:33 +00:00
|
|
|
if err := c.db.GetByID(ctx, s.CreatedWithApplicationID, gtsApplication); err != nil {
|
2021-04-19 17:42:19 +00:00
|
|
|
return nil, fmt.Errorf("error fetching application used to create status: %s", err)
|
|
|
|
}
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoApplication, err = c.AppToMastoPublic(ctx, gtsApplication)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error parsing application used to create status: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-20 10:26:56 +00:00
|
|
|
if s.Account == nil {
|
2021-08-25 13:34:33 +00:00
|
|
|
a, err := c.db.GetAccountByID(ctx, s.AccountID)
|
|
|
|
if err != nil {
|
2021-06-17 16:02:33 +00:00
|
|
|
return nil, fmt.Errorf("error getting status author: %s", err)
|
|
|
|
}
|
2021-08-20 10:26:56 +00:00
|
|
|
s.Account = a
|
2021-06-17 16:02:33 +00:00
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoAuthorAccount, err := c.AccountToMastoPublic(ctx, s.Account)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error parsing account of status author: %s", err)
|
|
|
|
}
|
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
mastoAttachments := []model.Attachment{}
|
2021-04-19 17:42:19 +00:00
|
|
|
// the status might already have some gts attachments on it if it's not been pulled directly from the database
|
|
|
|
// if so, we can directly convert the gts attachments into masto ones
|
2021-08-20 10:26:56 +00:00
|
|
|
if s.Attachments != nil {
|
|
|
|
for _, gtsAttachment := range s.Attachments {
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoAttachment, err := c.AttachmentToMasto(ctx, gtsAttachment)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error converting attachment with id %s: %s", gtsAttachment.ID, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
mastoAttachments = append(mastoAttachments, mastoAttachment)
|
|
|
|
}
|
|
|
|
// the status doesn't have gts attachments on it, but it does have attachment IDs
|
|
|
|
// in this case, we need to pull the gts attachments from the db to convert them into masto ones
|
|
|
|
} else {
|
2021-08-25 13:34:33 +00:00
|
|
|
for _, aID := range s.AttachmentIDs {
|
|
|
|
gtsAttachment, err := c.db.GetAttachmentByID(ctx, aID)
|
|
|
|
if err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error getting attachment with id %s: %s", aID, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoAttachment, err := c.AttachmentToMasto(ctx, gtsAttachment)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error converting attachment with id %s: %s", aID, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
mastoAttachments = append(mastoAttachments, mastoAttachment)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
mastoMentions := []model.Mention{}
|
2021-04-19 17:42:19 +00:00
|
|
|
// the status might already have some gts mentions on it if it's not been pulled directly from the database
|
|
|
|
// if so, we can directly convert the gts mentions into masto ones
|
2021-08-20 10:26:56 +00:00
|
|
|
if s.Mentions != nil {
|
|
|
|
for _, gtsMention := range s.Mentions {
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoMention, err := c.MentionToMasto(ctx, gtsMention)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error converting mention with id %s: %s", gtsMention.ID, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
mastoMentions = append(mastoMentions, mastoMention)
|
|
|
|
}
|
|
|
|
// the status doesn't have gts mentions on it, but it does have mention IDs
|
|
|
|
// in this case, we need to pull the gts mentions from the db to convert them into masto ones
|
|
|
|
} else {
|
2021-08-25 13:34:33 +00:00
|
|
|
for _, mID := range s.MentionIDs {
|
|
|
|
gtsMention, err := c.db.GetMention(ctx, mID)
|
|
|
|
if err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error getting mention with id %s: %s", mID, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoMention, err := c.MentionToMasto(ctx, gtsMention)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error converting mention with id %s: %s", gtsMention.ID, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
mastoMentions = append(mastoMentions, mastoMention)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
mastoTags := []model.Tag{}
|
2021-04-19 17:42:19 +00:00
|
|
|
// the status might already have some gts tags on it if it's not been pulled directly from the database
|
|
|
|
// if so, we can directly convert the gts tags into masto ones
|
2021-08-20 10:26:56 +00:00
|
|
|
if s.Tags != nil {
|
|
|
|
for _, gtsTag := range s.Tags {
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoTag, err := c.TagToMasto(ctx, gtsTag)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error converting tag with id %s: %s", gtsTag.ID, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
mastoTags = append(mastoTags, mastoTag)
|
|
|
|
}
|
|
|
|
// the status doesn't have gts tags on it, but it does have tag IDs
|
|
|
|
// in this case, we need to pull the gts tags from the db to convert them into masto ones
|
|
|
|
} else {
|
2021-08-20 10:26:56 +00:00
|
|
|
for _, t := range s.TagIDs {
|
2021-04-19 17:42:19 +00:00
|
|
|
gtsTag := >smodel.Tag{}
|
2021-08-25 13:34:33 +00:00
|
|
|
if err := c.db.GetByID(ctx, t, gtsTag); err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error getting tag with id %s: %s", t, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoTag, err := c.TagToMasto(ctx, gtsTag)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error converting tag with id %s: %s", gtsTag.ID, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
mastoTags = append(mastoTags, mastoTag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
mastoEmojis := []model.Emoji{}
|
2021-04-19 17:42:19 +00:00
|
|
|
// the status might already have some gts emojis on it if it's not been pulled directly from the database
|
|
|
|
// if so, we can directly convert the gts emojis into masto ones
|
2021-08-20 10:26:56 +00:00
|
|
|
if s.Emojis != nil {
|
|
|
|
for _, gtsEmoji := range s.Emojis {
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoEmoji, err := c.EmojiToMasto(ctx, gtsEmoji)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
mastoEmojis = append(mastoEmojis, mastoEmoji)
|
|
|
|
}
|
|
|
|
// the status doesn't have gts emojis on it, but it does have emoji IDs
|
|
|
|
// in this case, we need to pull the gts emojis from the db to convert them into masto ones
|
|
|
|
} else {
|
2021-08-20 10:26:56 +00:00
|
|
|
for _, e := range s.EmojiIDs {
|
2021-04-19 17:42:19 +00:00
|
|
|
gtsEmoji := >smodel.Emoji{}
|
2021-08-25 13:34:33 +00:00
|
|
|
if err := c.db.GetByID(ctx, e, gtsEmoji); err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error getting emoji with id %s: %s", e, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoEmoji, err := c.EmojiToMasto(ctx, gtsEmoji)
|
2021-04-19 17:42:19 +00:00
|
|
|
if err != nil {
|
2021-08-29 10:03:08 +00:00
|
|
|
l.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err)
|
|
|
|
continue
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
|
|
|
mastoEmojis = append(mastoEmojis, mastoEmoji)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
var mastoCard *model.Card
|
|
|
|
var mastoPoll *model.Poll
|
2021-04-19 17:42:19 +00:00
|
|
|
|
2021-06-17 16:02:33 +00:00
|
|
|
statusInteractions := &statusInteractions{}
|
2021-08-25 13:34:33 +00:00
|
|
|
si, err := c.interactionsWithStatusForAccount(ctx, s, requestingAccount)
|
2021-06-17 16:02:33 +00:00
|
|
|
if err == nil {
|
|
|
|
statusInteractions = si
|
|
|
|
}
|
|
|
|
|
2021-08-02 17:06:44 +00:00
|
|
|
apiStatus := &model.Status{
|
2021-04-19 17:42:19 +00:00
|
|
|
ID: s.ID,
|
|
|
|
CreatedAt: s.CreatedAt.Format(time.RFC3339),
|
|
|
|
InReplyToID: s.InReplyToID,
|
|
|
|
InReplyToAccountID: s.InReplyToAccountID,
|
|
|
|
Sensitive: s.Sensitive,
|
|
|
|
SpoilerText: s.ContentWarning,
|
2021-08-25 13:34:33 +00:00
|
|
|
Visibility: c.VisToMasto(ctx, s.Visibility),
|
2021-04-19 17:42:19 +00:00
|
|
|
Language: s.Language,
|
|
|
|
URI: s.URI,
|
|
|
|
URL: s.URL,
|
|
|
|
RepliesCount: repliesCount,
|
|
|
|
ReblogsCount: reblogsCount,
|
|
|
|
FavouritesCount: favesCount,
|
2021-06-17 16:02:33 +00:00
|
|
|
Favourited: statusInteractions.Faved,
|
|
|
|
Bookmarked: statusInteractions.Bookmarked,
|
|
|
|
Muted: statusInteractions.Muted,
|
|
|
|
Reblogged: statusInteractions.Reblogged,
|
2021-05-17 17:06:58 +00:00
|
|
|
Pinned: s.Pinned,
|
2021-04-19 17:42:19 +00:00
|
|
|
Content: s.Content,
|
|
|
|
Application: mastoApplication,
|
2021-05-27 14:06:24 +00:00
|
|
|
Account: mastoAuthorAccount,
|
2021-04-19 17:42:19 +00:00
|
|
|
MediaAttachments: mastoAttachments,
|
|
|
|
Mentions: mastoMentions,
|
|
|
|
Tags: mastoTags,
|
|
|
|
Emojis: mastoEmojis,
|
|
|
|
Card: mastoCard, // TODO: implement cards
|
|
|
|
Poll: mastoPoll, // TODO: implement polls
|
|
|
|
Text: s.Text,
|
2021-08-02 17:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if mastoRebloggedStatus != nil {
|
|
|
|
apiStatus.Reblog = &model.StatusReblogged{Status: mastoRebloggedStatus}
|
|
|
|
}
|
|
|
|
|
|
|
|
return apiStatus, nil
|
2021-04-19 17:42:19 +00:00
|
|
|
}
|
2021-05-08 12:25:55 +00:00
|
|
|
|
|
|
|
// VisToMasto converts a gts visibility into its mastodon equivalent
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) VisToMasto(ctx context.Context, m gtsmodel.Visibility) model.Visibility {
|
2021-05-08 12:25:55 +00:00
|
|
|
switch m {
|
|
|
|
case gtsmodel.VisibilityPublic:
|
|
|
|
return model.VisibilityPublic
|
|
|
|
case gtsmodel.VisibilityUnlocked:
|
|
|
|
return model.VisibilityUnlisted
|
|
|
|
case gtsmodel.VisibilityFollowersOnly, gtsmodel.VisibilityMutualsOnly:
|
|
|
|
return model.VisibilityPrivate
|
|
|
|
case gtsmodel.VisibilityDirect:
|
|
|
|
return model.VisibilityDirect
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
2021-05-09 12:06:06 +00:00
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) InstanceToMasto(ctx context.Context, i *gtsmodel.Instance) (*model.Instance, error) {
|
2021-05-09 12:06:06 +00:00
|
|
|
mi := &model.Instance{
|
2021-05-09 18:34:27 +00:00
|
|
|
URI: i.URI,
|
|
|
|
Title: i.Title,
|
|
|
|
Description: i.Description,
|
2021-05-09 12:06:06 +00:00
|
|
|
ShortDescription: i.ShortDescription,
|
2021-05-09 18:34:27 +00:00
|
|
|
Email: i.ContactEmail,
|
2021-05-22 13:51:20 +00:00
|
|
|
Version: i.Version,
|
2021-06-23 14:35:57 +00:00
|
|
|
Stats: make(map[string]int),
|
|
|
|
ContactAccount: &model.Account{},
|
2021-05-09 12:06:06 +00:00
|
|
|
}
|
|
|
|
|
2021-06-23 14:35:57 +00:00
|
|
|
// if the requested instance is *this* instance, we can add some extra information
|
2021-05-09 12:06:06 +00:00
|
|
|
if i.Domain == c.config.Host {
|
2021-06-23 14:35:57 +00:00
|
|
|
userCountKey := "user_count"
|
|
|
|
statusCountKey := "status_count"
|
|
|
|
domainCountKey := "domain_count"
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
userCount, err := c.db.CountInstanceUsers(ctx, c.config.Host)
|
2021-06-23 14:35:57 +00:00
|
|
|
if err == nil {
|
|
|
|
mi.Stats[userCountKey] = userCount
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
statusCount, err := c.db.CountInstanceStatuses(ctx, c.config.Host)
|
2021-06-23 14:35:57 +00:00
|
|
|
if err == nil {
|
|
|
|
mi.Stats[statusCountKey] = statusCount
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
domainCount, err := c.db.CountInstanceDomains(ctx, c.config.Host)
|
2021-06-23 14:35:57 +00:00
|
|
|
if err == nil {
|
|
|
|
mi.Stats[domainCountKey] = domainCount
|
|
|
|
}
|
|
|
|
|
2021-05-09 12:06:06 +00:00
|
|
|
mi.Registrations = c.config.AccountsConfig.OpenRegistration
|
|
|
|
mi.ApprovalRequired = c.config.AccountsConfig.RequireApproval
|
|
|
|
mi.InvitesEnabled = false // TODO
|
|
|
|
mi.MaxTootChars = uint(c.config.StatusesConfig.MaxChars)
|
2021-05-22 13:51:20 +00:00
|
|
|
mi.URLS = &model.InstanceURLs{
|
|
|
|
StreamingAPI: fmt.Sprintf("wss://%s", c.config.Host),
|
|
|
|
}
|
2021-06-24 12:26:08 +00:00
|
|
|
mi.Version = c.config.SoftwareVersion
|
2021-05-09 12:06:06 +00:00
|
|
|
}
|
|
|
|
|
2021-06-23 14:35:57 +00:00
|
|
|
// get the instance account if it exists and just skip if it doesn't
|
2021-08-25 13:34:33 +00:00
|
|
|
ia, err := c.db.GetInstanceAccount(ctx, "")
|
2021-08-20 10:26:56 +00:00
|
|
|
if err == nil {
|
|
|
|
if ia.HeaderMediaAttachment != nil {
|
|
|
|
mi.Thumbnail = ia.HeaderMediaAttachment.URL
|
2021-06-23 14:35:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-09 12:06:06 +00:00
|
|
|
// contact account is optional but let's try to get it
|
|
|
|
if i.ContactAccountID != "" {
|
2021-08-25 13:34:33 +00:00
|
|
|
if i.ContactAccount == nil {
|
|
|
|
contactAccount, err := c.db.GetAccountByID(ctx, i.ContactAccountID)
|
2021-05-09 12:06:06 +00:00
|
|
|
if err == nil {
|
2021-08-25 13:34:33 +00:00
|
|
|
i.ContactAccount = contactAccount
|
2021-05-09 12:06:06 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-25 13:34:33 +00:00
|
|
|
ma, err := c.AccountToMastoPublic(ctx, i.ContactAccount)
|
|
|
|
if err == nil {
|
|
|
|
mi.ContactAccount = ma
|
|
|
|
}
|
2021-05-09 12:06:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return mi, nil
|
|
|
|
}
|
2021-05-21 13:48:26 +00:00
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) RelationshipToMasto(ctx context.Context, r *gtsmodel.Relationship) (*model.Relationship, error) {
|
2021-05-21 13:48:26 +00:00
|
|
|
return &model.Relationship{
|
2021-05-21 21:04:59 +00:00
|
|
|
ID: r.ID,
|
|
|
|
Following: r.Following,
|
|
|
|
ShowingReblogs: r.ShowingReblogs,
|
|
|
|
Notifying: r.Notifying,
|
|
|
|
FollowedBy: r.FollowedBy,
|
|
|
|
Blocking: r.Blocking,
|
|
|
|
BlockedBy: r.BlockedBy,
|
|
|
|
Muting: r.Muting,
|
2021-05-21 13:48:26 +00:00
|
|
|
MutingNotifications: r.MutingNotifications,
|
2021-05-21 21:04:59 +00:00
|
|
|
Requested: r.Requested,
|
|
|
|
DomainBlocking: r.DomainBlocking,
|
|
|
|
Endorsed: r.Endorsed,
|
|
|
|
Note: r.Note,
|
2021-05-21 13:48:26 +00:00
|
|
|
}, nil
|
|
|
|
}
|
2021-05-27 14:06:24 +00:00
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) NotificationToMasto(ctx context.Context, n *gtsmodel.Notification) (*model.Notification, error) {
|
2021-08-20 10:26:56 +00:00
|
|
|
if n.TargetAccount == nil {
|
2021-08-25 13:34:33 +00:00
|
|
|
tAccount, err := c.db.GetAccountByID(ctx, n.TargetAccountID)
|
2021-08-20 10:26:56 +00:00
|
|
|
if err != nil {
|
2021-05-27 14:06:24 +00:00
|
|
|
return nil, fmt.Errorf("NotificationToMasto: error getting target account with id %s from the db: %s", n.TargetAccountID, err)
|
|
|
|
}
|
2021-08-20 10:26:56 +00:00
|
|
|
n.TargetAccount = tAccount
|
2021-05-27 14:06:24 +00:00
|
|
|
}
|
|
|
|
|
2021-08-20 10:26:56 +00:00
|
|
|
if n.OriginAccount == nil {
|
2021-08-25 13:34:33 +00:00
|
|
|
ogAccount, err := c.db.GetAccountByID(ctx, n.OriginAccountID)
|
2021-08-20 10:26:56 +00:00
|
|
|
if err != nil {
|
2021-05-27 14:06:24 +00:00
|
|
|
return nil, fmt.Errorf("NotificationToMasto: error getting origin account with id %s from the db: %s", n.OriginAccountID, err)
|
|
|
|
}
|
2021-08-20 10:26:56 +00:00
|
|
|
n.OriginAccount = ogAccount
|
2021-05-27 14:06:24 +00:00
|
|
|
}
|
2021-08-20 10:26:56 +00:00
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoAccount, err := c.AccountToMastoPublic(ctx, n.OriginAccount)
|
2021-05-27 14:06:24 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("NotificationToMasto: error converting account to masto: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var mastoStatus *model.Status
|
|
|
|
if n.StatusID != "" {
|
2021-08-20 10:26:56 +00:00
|
|
|
if n.Status == nil {
|
2021-08-25 13:34:33 +00:00
|
|
|
status, err := c.db.GetStatusByID(ctx, n.StatusID)
|
2021-08-20 10:26:56 +00:00
|
|
|
if err != nil {
|
2021-05-27 14:06:24 +00:00
|
|
|
return nil, fmt.Errorf("NotificationToMasto: error getting status with id %s from the db: %s", n.StatusID, err)
|
|
|
|
}
|
2021-08-20 10:26:56 +00:00
|
|
|
n.Status = status
|
2021-05-27 14:06:24 +00:00
|
|
|
}
|
|
|
|
|
2021-08-20 10:26:56 +00:00
|
|
|
if n.Status.Account == nil {
|
|
|
|
if n.Status.AccountID == n.TargetAccount.ID {
|
|
|
|
n.Status.Account = n.TargetAccount
|
|
|
|
} else if n.Status.AccountID == n.OriginAccount.ID {
|
|
|
|
n.Status.Account = n.OriginAccount
|
2021-05-27 14:06:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
2021-08-25 13:34:33 +00:00
|
|
|
mastoStatus, err = c.StatusToMasto(ctx, n.Status, nil)
|
2021-05-27 14:06:24 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("NotificationToMasto: error converting status to masto: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &model.Notification{
|
|
|
|
ID: n.ID,
|
|
|
|
Type: string(n.NotificationType),
|
|
|
|
CreatedAt: n.CreatedAt.Format(time.RFC3339),
|
|
|
|
Account: mastoAccount,
|
|
|
|
Status: mastoStatus,
|
|
|
|
}, nil
|
|
|
|
}
|
2021-07-05 11:23:03 +00:00
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
func (c *converter) DomainBlockToMasto(ctx context.Context, b *gtsmodel.DomainBlock, export bool) (*model.DomainBlock, error) {
|
2021-07-05 11:23:03 +00:00
|
|
|
|
|
|
|
domainBlock := &model.DomainBlock{
|
|
|
|
Domain: b.Domain,
|
|
|
|
PublicComment: b.PublicComment,
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we're exporting a domain block, return it with minimal information attached
|
|
|
|
if !export {
|
|
|
|
domainBlock.ID = b.ID
|
|
|
|
domainBlock.Obfuscate = b.Obfuscate
|
|
|
|
domainBlock.PrivateComment = b.PrivateComment
|
|
|
|
domainBlock.SubscriptionID = b.SubscriptionID
|
|
|
|
domainBlock.CreatedBy = b.CreatedByAccountID
|
|
|
|
domainBlock.CreatedAt = b.CreatedAt.Format(time.RFC3339)
|
|
|
|
}
|
|
|
|
|
|
|
|
return domainBlock, nil
|
|
|
|
}
|