Documentation
¶
Overview ¶
Package transformers provides consolidated Mastodon API transformations for converting between storage models and Mastodon API response formats.
Index ¶
- type AccountUpdateRequest
- type BatchProcessor
- type CachedTransformer
- type MastodonTransformer
- func (t *MastodonTransformer) AugmentAccountWithCounts(account *models.Account, followersCount, followingCount, statusesCount int)
- func (t *MastodonTransformer) AugmentAccountWithRelationship(account *models.Account, relationship *models.Relationship)
- func (t *MastodonTransformer) AugmentStatusWithCounts(status *models.Status, repliesCount, reblogsCount, favouritesCount int)
- func (t *MastodonTransformer) AugmentStatusWithUserInteractions(status *models.Status, favourited, reblogged, bookmarked, muted, pinned bool)
- func (t *MastodonTransformer) BuildLinkHeader(baseURL string, pagination *PaginationInfo) string
- func (t *MastodonTransformer) FormatMastodonAPIResponse(data interface{}) map[string]interface{}
- func (t *MastodonTransformer) FormatMastodonError(err error) map[string]interface{}
- func (t *MastodonTransformer) FormatPaginatedResponse(items []interface{}, pagination *PaginationInfo) map[string]interface{}
- func (t *MastodonTransformer) MastodonAccountParamsToStorage(params *models.UpdateCredentialsRequest, username string) (*AccountUpdateRequest, error)
- func (t *MastodonTransformer) MastodonStatusParamsToStorage(params *models.CreateStatusRequest, authorUsername string) (*StatusCreateRequest, error)
- func (t *MastodonTransformer) StorageAccountToMastodon(account *storage.Account) (*models.Account, error)
- func (t *MastodonTransformer) StorageNotificationToMastodon(notif *storageModels.Notification, account *models.Account, ...) (*models.Notification, error)
- func (t *MastodonTransformer) StorageStatusToMastodon(status *storageModels.Status, _ string) (*models.Status, error)
- func (t *MastodonTransformer) TransformStorageEmojiToMastodon(emojis []interface{}) []interface{}
- func (t *MastodonTransformer) TransformStorageMediaToMastodon(attachments []interface{}) []interface{}
- func (t *MastodonTransformer) WithTransformationFramework() *TransformationFrameworkBridge
- type PaginationInfo
- type StatusCreateRequest
- type TransformationFrameworkBridge
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountUpdateRequest ¶
type AccountUpdateRequest struct {
Username string `json:"username"`
DisplayName string `json:"display_name,omitempty"`
Bio string `json:"bio,omitempty"`
Locked bool `json:"locked"`
Bot bool `json:"bot"`
Discoverable bool `json:"discoverable"`
}
AccountUpdateRequest represents a request to update an account
type BatchProcessor ¶
type BatchProcessor struct {
// contains filtered or unexported fields
}
BatchProcessor provides batch processing for multiple transformations
func NewBatchProcessor ¶
func NewBatchProcessor(baseURL string) *BatchProcessor
NewBatchProcessor creates a new batch processor
func (*BatchProcessor) ProcessAccountBatch ¶
func (bp *BatchProcessor) ProcessAccountBatch(accounts []*storage.Account) ([]*models.Account, error)
ProcessAccountBatch processes multiple accounts in batch
func (*BatchProcessor) ProcessStatusBatch ¶
func (bp *BatchProcessor) ProcessStatusBatch(statuses []*storageModels.Status, viewerUsername string) ([]*models.Status, error)
ProcessStatusBatch processes multiple statuses in batch
type CachedTransformer ¶
type CachedTransformer struct {
*MastodonTransformer
// contains filtered or unexported fields
}
CachedTransformer provides caching for frequently accessed transformations
func NewCachedTransformer ¶
func NewCachedTransformer(baseURL string) *CachedTransformer
NewCachedTransformer creates a cached transformer
func (*CachedTransformer) ClearCache ¶
func (ct *CachedTransformer) ClearCache()
ClearCache clears the transformation cache
type MastodonTransformer ¶
type MastodonTransformer struct {
// contains filtered or unexported fields
}
MastodonTransformer provides consolidated Mastodon API transformations
func NewMastodonTransformer ¶
func NewMastodonTransformer(baseURL string) *MastodonTransformer
NewMastodonTransformer creates a new Mastodon API transformer
func (*MastodonTransformer) AugmentAccountWithCounts ¶
func (t *MastodonTransformer) AugmentAccountWithCounts(account *models.Account, followersCount, followingCount, statusesCount int)
AugmentAccountWithCounts adds follower/following/status counts to account
func (*MastodonTransformer) AugmentAccountWithRelationship ¶
func (t *MastodonTransformer) AugmentAccountWithRelationship(account *models.Account, relationship *models.Relationship)
AugmentAccountWithRelationship adds relationship status to account
func (*MastodonTransformer) AugmentStatusWithCounts ¶
func (t *MastodonTransformer) AugmentStatusWithCounts(status *models.Status, repliesCount, reblogsCount, favouritesCount int)
AugmentStatusWithCounts adds interaction counts to status
func (*MastodonTransformer) AugmentStatusWithUserInteractions ¶
func (t *MastodonTransformer) AugmentStatusWithUserInteractions(status *models.Status, favourited, reblogged, bookmarked, muted, pinned bool)
AugmentStatusWithUserInteractions adds user-specific interaction state to status
func (*MastodonTransformer) BuildLinkHeader ¶
func (t *MastodonTransformer) BuildLinkHeader(baseURL string, pagination *PaginationInfo) string
BuildLinkHeader builds a Link header for pagination
func (*MastodonTransformer) FormatMastodonAPIResponse ¶
func (t *MastodonTransformer) FormatMastodonAPIResponse(data interface{}) map[string]interface{}
FormatMastodonAPIResponse formats data for Mastodon API response
func (*MastodonTransformer) FormatMastodonError ¶
func (t *MastodonTransformer) FormatMastodonError(err error) map[string]interface{}
FormatMastodonError formats an error for Mastodon API response
func (*MastodonTransformer) FormatPaginatedResponse ¶
func (t *MastodonTransformer) FormatPaginatedResponse(items []interface{}, pagination *PaginationInfo) map[string]interface{}
FormatPaginatedResponse formats a paginated response with Link header information
func (*MastodonTransformer) MastodonAccountParamsToStorage ¶
func (t *MastodonTransformer) MastodonAccountParamsToStorage(params *models.UpdateCredentialsRequest, username string) (*AccountUpdateRequest, error)
MastodonAccountParamsToStorage converts Mastodon account update params to storage format
func (*MastodonTransformer) MastodonStatusParamsToStorage ¶
func (t *MastodonTransformer) MastodonStatusParamsToStorage(params *models.CreateStatusRequest, authorUsername string) (*StatusCreateRequest, error)
MastodonStatusParamsToStorage converts Mastodon status creation params to storage format
func (*MastodonTransformer) StorageAccountToMastodon ¶
func (t *MastodonTransformer) StorageAccountToMastodon(account *storage.Account) (*models.Account, error)
StorageAccountToMastodon converts storage Account to Mastodon API Account
func (*MastodonTransformer) StorageNotificationToMastodon ¶
func (t *MastodonTransformer) StorageNotificationToMastodon(notif *storageModels.Notification, account *models.Account, status *models.Status) (*models.Notification, error)
StorageNotificationToMastodon converts storage Notification to Mastodon API Notification
func (*MastodonTransformer) StorageStatusToMastodon ¶
func (t *MastodonTransformer) StorageStatusToMastodon(status *storageModels.Status, _ string) (*models.Status, error)
StorageStatusToMastodon converts storage Status to Mastodon API Status
func (*MastodonTransformer) TransformStorageEmojiToMastodon ¶
func (t *MastodonTransformer) TransformStorageEmojiToMastodon(emojis []interface{}) []interface{}
TransformStorageEmojiToMastodon converts storage emoji to Mastodon emoji format
func (*MastodonTransformer) TransformStorageMediaToMastodon ¶
func (t *MastodonTransformer) TransformStorageMediaToMastodon(attachments []interface{}) []interface{}
TransformStorageMediaToMastodon converts storage media to Mastodon media format
func (*MastodonTransformer) WithTransformationFramework ¶
func (t *MastodonTransformer) WithTransformationFramework() *TransformationFrameworkBridge
WithTransformationFramework enhances this transformer to work with the existing transformation framework
type PaginationInfo ¶
type PaginationInfo struct {
MaxID string `json:"max_id,omitempty"`
MinID string `json:"min_id,omitempty"`
SinceID string `json:"since_id,omitempty"`
Limit int `json:"limit,omitempty"`
NextCursor string `json:"next_cursor,omitempty"`
HasMore bool `json:"has_more,omitempty"`
}
PaginationInfo represents pagination metadata for Mastodon API responses
type StatusCreateRequest ¶
type StatusCreateRequest struct {
AuthorUsername string `json:"author_username"`
Content string `json:"content"`
Visibility string `json:"visibility"`
Sensitive bool `json:"sensitive"`
Language string `json:"language,omitempty"`
InReplyToID string `json:"in_reply_to_id,omitempty"`
MediaIDs []string `json:"media_ids,omitempty"`
}
StatusCreateRequest represents a request to create a status
type TransformationFrameworkBridge ¶
type TransformationFrameworkBridge struct {
// contains filtered or unexported fields
}
TransformationFrameworkBridge bridges this transformer with the existing transformation framework
func (*TransformationFrameworkBridge) Transform ¶
func (tfb *TransformationFrameworkBridge) Transform(_ context.Context, source *storage.Account) (models.Account, error)
Transform implements the Transformer interface for Account transformations
func (*TransformationFrameworkBridge) TransformList ¶
func (tfb *TransformationFrameworkBridge) TransformList(ctx context.Context, sources []*storage.Account) ([]models.Account, error)
TransformList implements the Transformer interface for Account list transformations