mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-28 09:53:32 -06:00
start adding AP <=> gts converters
This commit is contained in:
parent
8f85e2c621
commit
ab49ebe4af
1 changed files with 17 additions and 1 deletions
|
|
@ -29,11 +29,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// TypeConverter is an interface for the common action of converting between mastotypes (frontend, serializable) models,
|
// TypeConverter is an interface for the common action of converting between mastotypes (frontend, serializable) models,
|
||||||
// internal gts models used in the database, and models used in federation.
|
// internal gts models used in the database, and activitypub models used in federation.
|
||||||
//
|
//
|
||||||
// It requires access to the database because many of the conversions require pulling out database entries and counting them etc.
|
// It requires access to the database because many of the conversions require pulling out database entries and counting them etc.
|
||||||
// That said, it *absolutely should not* manipulate database entries in any way, only examine them.
|
// That said, it *absolutely should not* manipulate database entries in any way, only examine them.
|
||||||
type TypeConverter interface {
|
type TypeConverter interface {
|
||||||
|
/*
|
||||||
|
INTERNAL (gts) MODEL TO FRONTEND (mastodon) MODEL
|
||||||
|
*/
|
||||||
|
|
||||||
// AccountToMastoSensitive takes a db model account as a param, and returns a populated mastotype account, or an error
|
// AccountToMastoSensitive takes a db model account as a param, and returns a populated mastotype account, or an error
|
||||||
// if something goes wrong. The returned account should be ready to serialize on an API level, and may have sensitive fields,
|
// if something goes wrong. The returned account should be ready to serialize on an API level, and may have sensitive fields,
|
||||||
// so serve it only to an authorized user who should have permission to see it.
|
// so serve it only to an authorized user who should have permission to see it.
|
||||||
|
|
@ -72,8 +76,20 @@ type TypeConverter interface {
|
||||||
// VisToMasto converts a gts visibility into its mastodon equivalent
|
// VisToMasto converts a gts visibility into its mastodon equivalent
|
||||||
VisToMasto(m gtsmodel.Visibility) mastotypes.Visibility
|
VisToMasto(m gtsmodel.Visibility) mastotypes.Visibility
|
||||||
|
|
||||||
|
/*
|
||||||
|
FRONTEND (mastodon) MODEL TO INTERNAL (gts) MODEL
|
||||||
|
*/
|
||||||
|
|
||||||
// MastoVisToVis converts a mastodon visibility into its gts equivalent.
|
// MastoVisToVis converts a mastodon visibility into its gts equivalent.
|
||||||
MastoVisToVis(m mastotypes.Visibility) gtsmodel.Visibility
|
MastoVisToVis(m mastotypes.Visibility) gtsmodel.Visibility
|
||||||
|
|
||||||
|
/*
|
||||||
|
ACTIVITYPUB MODEL TO INTERNAL (gts) MODEL
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
INTERNAL (gts) MODEL TO ACTIVITYPUB MODEL
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
type converter struct {
|
type converter struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue