mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-23 12:16:38 +00:00
555ea8edfb
* start with export/import code * messing about with decoding/encoding * some more fiddling * stuff is WORKING * working pretty alright! * go fmt * fix up tests, add docs * start backup/restore doc * tweaks * credits * update advancedVisibility settings * update bun library -> v1.0.4 Signed-off-by: kim (grufwub) <grufwub@gmail.com> * update oauth library -> v4.3.1-SSB Signed-off-by: kim (grufwub) <grufwub@gmail.com> * handle oauth token scope, fix user.SigninCount + token.UserID Signed-off-by: kim (grufwub) <grufwub@gmail.com> * update oauth library --> v4.3.2-SSB Signed-off-by: kim (grufwub) <grufwub@gmail.com> * update sqlite library -> v1.13.0 Signed-off-by: kim (grufwub) <grufwub@gmail.com> * review changes * start with export/import code * messing about with decoding/encoding * some more fiddling * stuff is WORKING * working pretty alright! * go fmt * fix up tests, add docs * start backup/restore doc * tweaks * credits * update advancedVisibility settings * review changes Co-authored-by: kim (grufwub) <grufwub@gmail.com> Co-authored-by: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>
86 lines
2.7 KiB
Go
86 lines
2.7 KiB
Go
package typeutils
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
|
"github.com/superseriousbusiness/gotosocial/internal/id"
|
|
"github.com/superseriousbusiness/gotosocial/internal/util"
|
|
)
|
|
|
|
func (c *converter) FollowRequestToFollow(ctx context.Context, f *gtsmodel.FollowRequest) *gtsmodel.Follow {
|
|
return >smodel.Follow{
|
|
ID: f.ID,
|
|
CreatedAt: f.CreatedAt,
|
|
UpdatedAt: f.UpdatedAt,
|
|
AccountID: f.AccountID,
|
|
TargetAccountID: f.TargetAccountID,
|
|
ShowReblogs: f.ShowReblogs,
|
|
URI: f.URI,
|
|
Notify: f.Notify,
|
|
}
|
|
}
|
|
|
|
func (c *converter) StatusToBoost(ctx context.Context, s *gtsmodel.Status, boostingAccount *gtsmodel.Account) (*gtsmodel.Status, error) {
|
|
// the wrapper won't use the same ID as the boosted status so we generate some new UUIDs
|
|
uris := util.GenerateURIsForAccount(boostingAccount.Username, c.config.Protocol, c.config.Host)
|
|
boostWrapperStatusID, err := id.NewULID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
boostWrapperStatusURI := fmt.Sprintf("%s/%s", uris.StatusesURI, boostWrapperStatusID)
|
|
boostWrapperStatusURL := fmt.Sprintf("%s/%s", uris.StatusesURL, boostWrapperStatusID)
|
|
|
|
local := true
|
|
if boostingAccount.Domain != "" {
|
|
local = false
|
|
}
|
|
|
|
boostWrapperStatus := >smodel.Status{
|
|
ID: boostWrapperStatusID,
|
|
URI: boostWrapperStatusURI,
|
|
URL: boostWrapperStatusURL,
|
|
|
|
// the boosted status is not created now, but the boost certainly is
|
|
CreatedAt: time.Now(),
|
|
UpdatedAt: time.Now(),
|
|
Local: local,
|
|
AccountID: boostingAccount.ID,
|
|
AccountURI: boostingAccount.URI,
|
|
|
|
// replies can be boosted, but boosts are never replies
|
|
InReplyToID: "",
|
|
InReplyToAccountID: "",
|
|
|
|
// these will all be wrapped in the boosted status so set them empty here
|
|
AttachmentIDs: []string{},
|
|
TagIDs: []string{},
|
|
MentionIDs: []string{},
|
|
EmojiIDs: []string{},
|
|
|
|
// the below fields will be taken from the target status
|
|
Content: s.Content,
|
|
ContentWarning: s.ContentWarning,
|
|
ActivityStreamsType: s.ActivityStreamsType,
|
|
Sensitive: s.Sensitive,
|
|
Language: s.Language,
|
|
Text: s.Text,
|
|
BoostOfID: s.ID,
|
|
BoostOfAccountID: s.AccountID,
|
|
Visibility: s.Visibility,
|
|
Federated: s.Federated,
|
|
Boostable: s.Boostable,
|
|
Replyable: s.Replyable,
|
|
Likeable: s.Likeable,
|
|
|
|
// attach these here for convenience -- the boosted status/account won't go in the DB
|
|
// but they're needed in the processor and for the frontend. Since we have them, we can
|
|
// attach them so we don't need to fetch them again later (save some DB calls)
|
|
BoostOf: s,
|
|
}
|
|
|
|
return boostWrapperStatus, nil
|
|
}
|