mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Implement markers API (#1989)
* Implement markers API Fixes #1856 * Correct import grouping in markers files * Regenerate Swagger for markers API * Shorten names for readability * Cache markers for 6 hours * Update DB ref * Update envparsing.sh
This commit is contained in:
@@ -1166,6 +1166,26 @@ func (c *converter) ListToAPIList(ctx context.Context, l *gtsmodel.List) (*apimo
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *converter) MarkersToAPIMarker(ctx context.Context, markers []*gtsmodel.Marker) (*apimodel.Marker, error) {
|
||||
apiMarker := &apimodel.Marker{}
|
||||
for _, marker := range markers {
|
||||
apiTimelineMarker := &apimodel.TimelineMarker{
|
||||
LastReadID: marker.LastReadID,
|
||||
UpdatedAt: util.FormatISO8601(marker.UpdatedAt),
|
||||
Version: marker.Version,
|
||||
}
|
||||
switch apimodel.MarkerName(marker.Name) {
|
||||
case apimodel.MarkerNameHome:
|
||||
apiMarker.Home = apiTimelineMarker
|
||||
case apimodel.MarkerNameNotifications:
|
||||
apiMarker.Notifications = apiTimelineMarker
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown marker timeline name: %s", marker.Name)
|
||||
}
|
||||
}
|
||||
return apiMarker, nil
|
||||
}
|
||||
|
||||
// convertAttachmentsToAPIAttachments will convert a slice of GTS model attachments to frontend API model attachments, falling back to IDs if no GTS models supplied.
|
||||
func (c *converter) convertAttachmentsToAPIAttachments(ctx context.Context, attachments []*gtsmodel.MediaAttachment, attachmentIDs []string) ([]apimodel.Attachment, error) {
|
||||
var errs gtserror.MultiError
|
||||
|
Reference in New Issue
Block a user