Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] add support for receiving federated status edits #3597

Conversation

NyaaaWhatsUpDoc
Copy link
Member

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc commented Dec 3, 2024

Description

Adds support for GoToSocial properly handling federated status edits. When we receive a status update activity we now correctly store the current state as a historical edit in a new database table, and update the state to the newly received edit. This also handles the case of re-fetching a status we haven't received an update for, but then notice a change in.

Some other changes of note:

  • adds getBunColumnDef() migration utliity function which generates the database column definition that bun would normally generate for a given struct field, which greatly simplifies manually adding new columns not having to write the type manually
  • drops the unused mentions.updated_at database column
  • drops the unused media_attachments.updated_at database column
  • adds compile-time type checking of a bunch of our AP interface-able types
  • removes the error signature from id.NewULIDFromTime() as we handle the end result in exactly the same manner all over the codebase
  • tweaks federated status updates to now only update the necessary columns, possibly now a little cheaper computationally

Checklist

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have not leveraged AI to create the proposed changes.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • I/we have commented the added code, particularly in hard-to-understand areas.
  • I/we have made any necessary changes to documentation.
  • I/we have added tests that cover new code.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc force-pushed the feature/add-status-edit-db-support branch from 9794864 to 880dd89 Compare December 3, 2024 15:26
@NyaaaWhatsUpDoc NyaaaWhatsUpDoc marked this pull request as ready for review December 3, 2024 16:07
@tsmethurst
Copy link
Contributor

Big juicy PR! Gonna review it now.

func statusChanged(existing, latest *gtsmodel.Status) bool {
return existing.Content != latest.Content ||
existing.ContentWarning != latest.ContentWarning ||
!slices.Equal(existing.AttachmentIDs, latest.AttachmentIDs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to also edit image alt text and have that appear as an update? I'm not sure how it works exactly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already handle that, though currently in the fetchStatusAttachments() function so tbh i might do some fiddling and also see if mastodon handles media description changes as historic status edits

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there we go, tweaked! 5347924

@tsmethurst
Copy link
Contributor

Looking great :)

@tsmethurst
Copy link
Contributor

When you're happy then squerge away pal :)

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc merged commit 23fc70f into superseriousbusiness:main Dec 5, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants