From ba9d6b467a1f03447789844048d913738c843569 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 10 Nov 2023 19:29:26 +0100 Subject: [feature] Media attachment placeholders (#2331) * [feature] Use placeholders for unknown media types * fix read of underreported small files * switch to reduce nesting * simplify cleanup --- testrig/testmodels.go | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) (limited to 'testrig/testmodels.go') diff --git a/testrig/testmodels.go b/testrig/testmodels.go index a9c9777dd..d27f91e11 100644 --- a/testrig/testmodels.go +++ b/testrig/testmodels.go @@ -1114,6 +1114,113 @@ func NewTestAttachments() map[string]*gtsmodel.MediaAttachment { Header: util.Ptr(true), Cached: util.Ptr(true), }, + "remote_account_2_status_1_attachment_1": { + ID: "01HE7Y3C432WRSNS10EZM86SA5", + StatusID: "01HE7XJ1CG84TBKH5V9XKBVGF5", + URL: "http://localhost:8080/fileserver/01FHMQX3GAABWSM0S2VZEC2SWC/attachment/original/01HE7Y3C432WRSNS10EZM86SA5.jpg", + RemoteURL: "http://example.org/fileserver/01HE7Y659ZWZ02JM4AWYJZ176Q/attachment/original/01HE7Y6G0EMCKST3Q0914WW0MS.jpg", + CreatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + Type: gtsmodel.FileTypeImage, + FileMeta: gtsmodel.FileMeta{ + Original: gtsmodel.Original{ + Width: 3000, + Height: 2000, + Size: 6000000, + Aspect: 1.5, + }, + Small: gtsmodel.Small{ + Width: 512, + Height: 341, + Size: 174592, + Aspect: 1.5014663, + }, + Focus: gtsmodel.Focus{ + X: 0, + Y: 0, + }, + }, + AccountID: "01FHMQX3GAABWSM0S2VZEC2SWC", + Description: "Photograph of a sloth, Public Domain.", + Blurhash: "LNEC{|w}0K9GsEtPM|j[NFbHoeof", + Processing: 2, + File: gtsmodel.File{ + Path: "01FHMQX3GAABWSM0S2VZEC2SWC/attachment/original/01HE7Y3C432WRSNS10EZM86SA5.jpg", + ContentType: "image/jpg", + FileSize: 5450054, + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + }, + Thumbnail: gtsmodel.Thumbnail{ + Path: "01FHMQX3GAABWSM0S2VZEC2SWC/attachment/small/01HE7Y3C432WRSNS10EZM86SA5.jpg", + ContentType: "image/jpeg", + FileSize: 50820, + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + URL: "http://localhost:8080/fileserver/01FHMQX3GAABWSM0S2VZEC2SWC/attachment/small/01HE7Y3C432WRSNS10EZM86SA5.jpg", + }, + Avatar: util.Ptr(false), + Header: util.Ptr(false), + Cached: util.Ptr(true), + }, + "remote_account_2_status_1_attachment_2": { + ID: "01HE7ZFX9GKA5ZZVD4FACABSS9", + StatusID: "01HE7XJ1CG84TBKH5V9XKBVGF5", + URL: "http://localhost:8080/fileserver/01FHMQX3GAABWSM0S2VZEC2SWC/attachment/original/01HE7ZFX9GKA5ZZVD4FACABSS9.svg", + RemoteURL: "http://example.org/fileserver/01HE7Y659ZWZ02JM4AWYJZ176Q/attachment/original/01HE7ZGJYTSYMXF927GF9353KR.svg", + CreatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + Type: gtsmodel.FileTypeUnknown, + FileMeta: gtsmodel.FileMeta{}, + AccountID: "01FHMQX3GAABWSM0S2VZEC2SWC", + Description: "SVG line art of a sloth, public domain", + Blurhash: "L26*j+~qE1RP?wxut7ofRlM{R*of", + Processing: 2, + File: gtsmodel.File{ + Path: "01FHMQX3GAABWSM0S2VZEC2SWC/attachment/original/01HE7ZFX9GKA5ZZVD4FACABSS9.svg", + ContentType: "image/svg", + FileSize: 147819, + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + }, + Thumbnail: gtsmodel.Thumbnail{ + Path: "01FHMQX3GAABWSM0S2VZEC2SWC/attachment/small/01HE7ZFX9GKA5ZZVD4FACABSS9.jpg", + ContentType: "image/jpeg", + FileSize: 0, + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + URL: "http://localhost:8080/fileserver/01FHMQX3GAABWSM0S2VZEC2SWC/attachment/small/01HE7ZFX9GKA5ZZVD4FACABSS9.jpg", + }, + Avatar: util.Ptr(false), + Header: util.Ptr(false), + Cached: util.Ptr(false), + }, + "remote_account_2_status_1_attachment_3": { + ID: "01HE88YG74PVAB81PX2XA9F3FG", + StatusID: "01HE7XJ1CG84TBKH5V9XKBVGF5", + URL: "http://localhost:8080/fileserver/01FHMQX3GAABWSM0S2VZEC2SWC/attachment/original/01HE88YG74PVAB81PX2XA9F3FG.mp3", + RemoteURL: "http://example.org/fileserver/01HE7Y659ZWZ02JM4AWYJZ176Q/attachment/original/01HE892Y8ZS68TQCNPX7J888P3.mp3", + CreatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + Type: gtsmodel.FileTypeUnknown, + FileMeta: gtsmodel.FileMeta{}, + AccountID: "01FHMQX3GAABWSM0S2VZEC2SWC", + Description: "Jolly salsa song, public domain.", + Blurhash: "", + Processing: 2, + File: gtsmodel.File{ + Path: "01FHMQX3GAABWSM0S2VZEC2SWC/attachment/original/01HE88YG74PVAB81PX2XA9F3FG.mp3", + ContentType: "audio/mpeg", + FileSize: 147819, + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + }, + Thumbnail: gtsmodel.Thumbnail{ + Path: "01FHMQX3GAABWSM0S2VZEC2SWC/attachment/small/01HE88YG74PVAB81PX2XA9F3FG.jpg", + ContentType: "image/jpeg", + FileSize: 0, + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + URL: "http://localhost:8080/fileserver/01FHMQX3GAABWSM0S2VZEC2SWC/attachment/small/01HE88YG74PVAB81PX2XA9F3FG.jpg", + }, + Avatar: util.Ptr(false), + Header: util.Ptr(false), + Cached: util.Ptr(false), + }, } } @@ -1279,6 +1386,10 @@ func newTestStoredAttachments() map[string]filenames { Original: "thoughtsofdog-original.jpg", Small: "thoughtsofdog-small.jpg", }, + "remote_account_2_status_1_attachment_1": { + Original: "sloth-original.jpg", + Small: "sloth-small.jpg", + }, } } @@ -1830,6 +1941,33 @@ func NewTestStatuses() map[string]*gtsmodel.Status { ActivityStreamsType: ap.ActivityQuestion, PollID: "01HEN2R65468ZG657C4ZPHJ4EX", }, + "remote_account_2_status_1": { + ID: "01HE7XJ1CG84TBKH5V9XKBVGF5", + URI: "http://example.org/users/Some_User/statuses/01HE7XJ1CG84TBKH5V9XKBVGF5", + URL: "http://example.org/@Some_User/statuses/01HE7XJ1CG84TBKH5V9XKBVGF5", + Content: `
hi @admin here's some media for ya
`, + AttachmentIDs: []string{"01HE7Y3C432WRSNS10EZM86SA5", "01HE7ZFX9GKA5ZZVD4FACABSS9", "01HE88YG74PVAB81PX2XA9F3FG"}, + CreatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + Local: util.Ptr(false), + AccountURI: "http://example.org/users/Some_User", + MentionIDs: []string{"01HE7XQNMKTVC8MNPCE1JGK4J3"}, + AccountID: "01FHMQX3GAABWSM0S2VZEC2SWC", + InReplyToID: "01F8MH75CBF9JFX4ZAD54N0W0R", + InReplyToAccountID: "01F8MH17FWEB39HZJ76B6VXSKF", + InReplyToURI: "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R", + BoostOfID: "", + ContentWarning: "", + Visibility: gtsmodel.VisibilityPublic, + Sensitive: util.Ptr(false), + Language: "en", + CreatedWithApplicationID: "", + Federated: util.Ptr(true), + Boostable: util.Ptr(true), + Replyable: util.Ptr(true), + Likeable: util.Ptr(true), + ActivityStreamsType: ap.ObjectNote, + }, } } @@ -2123,6 +2261,18 @@ func NewTestMentions() map[string]*gtsmodel.Mention { TargetAccountURI: "http://localhost:8080/users/the_mighty_zork", TargetAccountURL: "http://localhost:8080/@the_mighty_zork", }, + "remote_account_2_mention_admin": { + ID: "01HE7XQNMKTVC8MNPCE1JGK4J3", + StatusID: "01HE7XJ1CG84TBKH5V9XKBVGF5", + CreatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + UpdatedAt: TimeMustParse("2023-11-02T12:44:25+02:00"), + OriginAccountID: "01FHMQX3GAABWSM0S2VZEC2SWC", + OriginAccountURI: "http://example.org/users/Some_User", + TargetAccountID: "01F8MH17FWEB39HZJ76B6VXSKF", + NameString: "@admin@localhost:8080", + TargetAccountURI: "http://localhost:8080/users/admin", + TargetAccountURL: "http://localhost:8080/@admin", + }, } } -- cgit v1.2.3