From 167971771ee5614e383d8aa1a2a4359d45091678 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 2 Oct 2023 19:33:03 -0400 Subject: [PATCH 1/2] Send `updated` parameter with `Update` activities Per the Mastodon docs, this ensures the activity correctly updates posts there. https://docs.joinmastodon.org/spec/activitypub/#supported-activities-for-statuses --- activitypub.go | 1 + go.mod | 2 +- go.sum | 6 ++---- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/activitypub.go b/activitypub.go index 02fb9e7..c9dd9c8 100644 --- a/activitypub.go +++ b/activitypub.go @@ -718,6 +718,7 @@ func federatePost(app *App, p *PublicPost, collID int64, isUpdate bool) error { // create a new "Create" activity // with our article as object if isUpdate { + na.Updated = p.Updated activity = activitystreams.NewUpdateActivity(na) } else { activity = activitystreams.NewCreateActivity(na) diff --git a/go.mod b/go.mod index 136c9a6..d657f66 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/writeas/monday v1.3.0 github.com/writeas/saturday v1.7.2-0.20200427193424-392b95a03320 github.com/writeas/slug v1.2.0 - github.com/writeas/web-core v1.6.0 + github.com/writeas/web-core v1.6.1-0.20231002232751-adbbafe3ee0c github.com/writefreely/go-gopher v0.0.0-20220429181814-40127126f83b github.com/writefreely/go-nodeinfo v1.2.0 golang.org/x/crypto v0.13.0 diff --git a/go.sum b/go.sum index f2ab3a8..48f67cc 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,6 @@ github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/writeas/activity v0.1.2 h1:Y12B5lIrabfqKE7e7HFCWiXrlfXljr9tlkFm2mp7DgY= github.com/writeas/activity v0.1.2/go.mod h1:mYYgiewmEM+8tlifirK/vl6tmB2EbjYaxwb+ndUw5T0= -github.com/writeas/activityserve v0.0.0-20200409150223-d7ab3eaa4481 h1:BiSivIxLQFcKoUorpNN3rNwwFG5bITPnqUSyIccfdh0= -github.com/writeas/activityserve v0.0.0-20200409150223-d7ab3eaa4481/go.mod h1:4akDJSl+sSp+QhrQKMqzAqdV1gJ1pPx6XPI77zgMM8o= github.com/writeas/activityserve v0.0.0-20230428180247-dc13a4f4d835 h1:bm/7gYo6y3GxtTa1qyUFyCk29CTnBAKt7z4D2MASYrw= github.com/writeas/activityserve v0.0.0-20230428180247-dc13a4f4d835/go.mod h1:4akDJSl+sSp+QhrQKMqzAqdV1gJ1pPx6XPI77zgMM8o= github.com/writeas/go-strip-markdown/v2 v2.1.1 h1:hAxUM21Uhznf/FnbVGiJciqzska6iLei22Ijc3q2e28= @@ -145,8 +143,8 @@ github.com/writeas/saturday v1.7.2-0.20200427193424-392b95a03320 h1:PozPZ29CQ/xt github.com/writeas/saturday v1.7.2-0.20200427193424-392b95a03320/go.mod h1:ETE1EK6ogxptJpAgUbcJD0prAtX48bSloie80+tvnzQ= github.com/writeas/slug v1.2.0 h1:EMQ+cwLiOcA6EtFwUgyw3Ge18x9uflUnOnR6bp/J+/g= github.com/writeas/slug v1.2.0/go.mod h1:RE8shOqQP3YhsfsQe0L3RnuejfQ4Mk+JjY5YJQFubfQ= -github.com/writeas/web-core v1.6.0 h1:qOcnbB4RE/kG9g+3ycMRqepj2PljDg2whG/K4A0QB48= -github.com/writeas/web-core v1.6.0/go.mod h1:7+idL4Y4woF7MnUfNX2mvkaQ8nLIJXths2y5iYPtA3k= +github.com/writeas/web-core v1.6.1-0.20231002232751-adbbafe3ee0c h1:OcubGLNP26NPbe7s8ppUi8pl1IPKMHZ7Wu+jjxDATBg= +github.com/writeas/web-core v1.6.1-0.20231002232751-adbbafe3ee0c/go.mod h1:7+idL4Y4woF7MnUfNX2mvkaQ8nLIJXths2y5iYPtA3k= github.com/writefreely/go-gopher v0.0.0-20220429181814-40127126f83b h1:h3NzB8OZ50NNi5k9yrFeyFszt3LyqyVK4+xUHFYY8B0= github.com/writefreely/go-gopher v0.0.0-20220429181814-40127126f83b/go.mod h1:T2UVVzt+R5KSSZe2xRSytnwc2M9AoDegi7foeIsik+M= github.com/writefreely/go-nodeinfo v1.2.0 h1:La+YbTCvmpTwFhBSlebWDDL81N88Qf/SCAvRLR7F8ss= From 273267343ab8ba545f18ba502133dd9253f45312 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 2 Oct 2023 21:35:23 -0400 Subject: [PATCH 2/2] Ensure Updated property can be omitted Now, the web-core pkg uses a pointer instead of a var, so we don't send a zero time.Time value out via ActivityPub. --- activitypub.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/activitypub.go b/activitypub.go index c9dd9c8..01aeadd 100644 --- a/activitypub.go +++ b/activitypub.go @@ -718,7 +718,7 @@ func federatePost(app *App, p *PublicPost, collID int64, isUpdate bool) error { // create a new "Create" activity // with our article as object if isUpdate { - na.Updated = p.Updated + na.Updated = &p.Updated activity = activitystreams.NewUpdateActivity(na) } else { activity = activitystreams.NewCreateActivity(na) diff --git a/go.mod b/go.mod index d657f66..979bae1 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/writeas/monday v1.3.0 github.com/writeas/saturday v1.7.2-0.20200427193424-392b95a03320 github.com/writeas/slug v1.2.0 - github.com/writeas/web-core v1.6.1-0.20231002232751-adbbafe3ee0c + github.com/writeas/web-core v1.6.1-0.20231003013047-d81124d45431 github.com/writefreely/go-gopher v0.0.0-20220429181814-40127126f83b github.com/writefreely/go-nodeinfo v1.2.0 golang.org/x/crypto v0.13.0 diff --git a/go.sum b/go.sum index 48f67cc..3dbbf9f 100644 --- a/go.sum +++ b/go.sum @@ -143,8 +143,8 @@ github.com/writeas/saturday v1.7.2-0.20200427193424-392b95a03320 h1:PozPZ29CQ/xt github.com/writeas/saturday v1.7.2-0.20200427193424-392b95a03320/go.mod h1:ETE1EK6ogxptJpAgUbcJD0prAtX48bSloie80+tvnzQ= github.com/writeas/slug v1.2.0 h1:EMQ+cwLiOcA6EtFwUgyw3Ge18x9uflUnOnR6bp/J+/g= github.com/writeas/slug v1.2.0/go.mod h1:RE8shOqQP3YhsfsQe0L3RnuejfQ4Mk+JjY5YJQFubfQ= -github.com/writeas/web-core v1.6.1-0.20231002232751-adbbafe3ee0c h1:OcubGLNP26NPbe7s8ppUi8pl1IPKMHZ7Wu+jjxDATBg= -github.com/writeas/web-core v1.6.1-0.20231002232751-adbbafe3ee0c/go.mod h1:7+idL4Y4woF7MnUfNX2mvkaQ8nLIJXths2y5iYPtA3k= +github.com/writeas/web-core v1.6.1-0.20231003013047-d81124d45431 h1:ruqL2u87k504PXkR/fC4DcfZyyHmCindlpjOQKmyOsY= +github.com/writeas/web-core v1.6.1-0.20231003013047-d81124d45431/go.mod h1:7+idL4Y4woF7MnUfNX2mvkaQ8nLIJXths2y5iYPtA3k= github.com/writefreely/go-gopher v0.0.0-20220429181814-40127126f83b h1:h3NzB8OZ50NNi5k9yrFeyFszt3LyqyVK4+xUHFYY8B0= github.com/writefreely/go-gopher v0.0.0-20220429181814-40127126f83b/go.mod h1:T2UVVzt+R5KSSZe2xRSytnwc2M9AoDegi7foeIsik+M= github.com/writefreely/go-nodeinfo v1.2.0 h1:La+YbTCvmpTwFhBSlebWDDL81N88Qf/SCAvRLR7F8ss=