mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-09 21:38:08 -06:00
[bugfix] Fix images not being processed correctly sometimes (#437)
* bump exif-terminator to latest version * add and test giant turnip from turnip.farm * don't error if content property is nil
This commit is contained in:
parent
36b2f2b4e6
commit
25cab0e1f4
22 changed files with 245 additions and 46 deletions
|
|
@ -50,17 +50,15 @@ type DereferencerStandardTestSuite struct {
|
|||
dereferencer dereferencing.Dereferencer
|
||||
}
|
||||
|
||||
func (suite *DereferencerStandardTestSuite) SetupSuite() {
|
||||
func (suite *DereferencerStandardTestSuite) SetupTest() {
|
||||
testrig.InitTestConfig()
|
||||
testrig.InitTestLog()
|
||||
|
||||
suite.testAccounts = testrig.NewTestAccounts()
|
||||
suite.testRemoteStatuses = testrig.NewTestFediStatuses()
|
||||
suite.testRemotePeople = testrig.NewTestFediPeople()
|
||||
suite.testRemoteGroups = testrig.NewTestFediGroups()
|
||||
suite.testRemoteAttachments = testrig.NewTestFediAttachments("../../../testrig/media")
|
||||
}
|
||||
|
||||
func (suite *DereferencerStandardTestSuite) SetupTest() {
|
||||
testrig.InitTestLog()
|
||||
testrig.InitTestConfig()
|
||||
|
||||
suite.db = testrig.NewTestDB()
|
||||
suite.storage = testrig.NewTestStorage()
|
||||
|
|
|
|||
|
|
@ -131,6 +131,53 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
|
|||
suite.False(m.Silent)
|
||||
}
|
||||
|
||||
func (suite *StatusTestSuite) TestDereferenceStatusWithImageAndNoContent() {
|
||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||
|
||||
statusURL := testrig.URLMustParse("https://turnip.farm/users/turniplover6969/statuses/70c53e54-3146-42d5-a630-83c8b6c7c042")
|
||||
status, statusable, new, err := suite.dereferencer.GetRemoteStatus(context.Background(), fetchingAccount.Username, statusURL, false, false)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(status)
|
||||
suite.NotNil(statusable)
|
||||
suite.True(new)
|
||||
|
||||
// status values should be set
|
||||
suite.Equal("https://turnip.farm/users/turniplover6969/statuses/70c53e54-3146-42d5-a630-83c8b6c7c042", status.URI)
|
||||
suite.Equal("https://turnip.farm/@turniplover6969/70c53e54-3146-42d5-a630-83c8b6c7c042", status.URL)
|
||||
suite.Equal("", status.Content)
|
||||
suite.Equal("https://turnip.farm/users/turniplover6969", status.AccountURI)
|
||||
suite.False(status.Local)
|
||||
suite.Empty(status.ContentWarning)
|
||||
suite.Equal(gtsmodel.VisibilityPublic, status.Visibility)
|
||||
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
|
||||
|
||||
// status should be in the database
|
||||
dbStatus, err := suite.db.GetStatusByURI(context.Background(), status.URI)
|
||||
suite.NoError(err)
|
||||
suite.Equal(status.ID, dbStatus.ID)
|
||||
suite.True(dbStatus.Federated)
|
||||
suite.True(dbStatus.Boostable)
|
||||
suite.True(dbStatus.Replyable)
|
||||
suite.True(dbStatus.Likeable)
|
||||
|
||||
// account should be in the database now too
|
||||
account, err := suite.db.GetAccountByURI(context.Background(), status.AccountURI)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(account)
|
||||
suite.True(account.Discoverable)
|
||||
suite.Equal("https://turnip.farm/users/turniplover6969", account.URI)
|
||||
suite.Equal("I just think they're neat", account.Note)
|
||||
suite.Equal("Turnip Lover 6969", account.DisplayName)
|
||||
suite.Equal("turniplover6969", account.Username)
|
||||
suite.NotNil(account.PublicKey)
|
||||
suite.Nil(account.PrivateKey)
|
||||
|
||||
// we should have an attachment in the database
|
||||
a := >smodel.MediaAttachment{}
|
||||
err = suite.db.GetWhere(context.Background(), []db.Where{{Key: "status_id", Value: status.ID}}, a)
|
||||
suite.NoError(err)
|
||||
}
|
||||
|
||||
func TestStatusTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(StatusTestSuite))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ func deriveThumbnail(r io.Reader, contentType string, createBlurhash bool) (*ima
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error decoding image as %s: %s", contentType, err)
|
||||
}
|
||||
|
||||
if i == nil {
|
||||
|
|
@ -151,7 +151,7 @@ func deriveThumbnail(r io.Reader, contentType string, createBlurhash bool) (*ima
|
|||
tiny := resize.Thumbnail(32, 32, thumb, resize.NearestNeighbor)
|
||||
bh, err := blurhash.Encode(4, 3, tiny)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error creating blurhash: %s", err)
|
||||
}
|
||||
im.blurhash = bh
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ func deriveThumbnail(r io.Reader, contentType string, createBlurhash bool) (*ima
|
|||
// Quality isn't extremely important for thumbnails, so 75 is "good enough"
|
||||
Quality: 75,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error encoding thumbnail: %s", err)
|
||||
}
|
||||
im.small = out.Bytes()
|
||||
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ func (p *ProcessingMedia) store(ctx context.Context) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("store: error executing data function: %s", err)
|
||||
}
|
||||
logrus.Tracef("store: reading %d bytes from data function for media %s", fileSize, p.attachment.URL)
|
||||
|
||||
// defer closing the reader when we're done with it
|
||||
defer func() {
|
||||
|
|
@ -342,6 +343,7 @@ func (p *ProcessingMedia) store(ctx context.Context) error {
|
|||
return p.postData(ctx)
|
||||
}
|
||||
|
||||
logrus.Tracef("store: finished storing initial data for attachment %s", p.attachment.URL)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue