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

feat(worker/activitypub): implement mastodon worker to transform AP objects #431

Conversation

FrankLi123
Copy link
Contributor

@FrankLi123 FrankLi123 commented Jul 24, 2024

Summary

Checklist

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

…ith 'Create' type (transform to activities in SocialPost and Social Comments)
@FrankLi123 FrankLi123 self-assigned this Jul 24, 2024
@FrankLi123 FrankLi123 requested a review from brucexc July 24, 2024 10:12
@FrankLi123 FrankLi123 force-pushed the feat/integrate-activitypub-mastodon-worker branch from e496004 to 53f97b9 Compare July 24, 2024 10:39
@FrankLi123 FrankLi123 changed the title Feat/integrate activitypub mastodon worker feat(worker/activitypub): implement mastodon worker to transform AP objects Jul 24, 2024
@FrankLi123
Copy link
Contributor Author

@@ -33,6 +34,10 @@ endpoints:
url: https://rpc.ankr.com/eth
http_headers:
user-agent: rss3-node
mastodon:
url: https://30.10.000.00:9092/
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
url: https://30.10.000.00:9092/
The endpoint should be defined in the configuration file rather than hardcoding them. Sensitive information like this should not appear in the code, as it poses a security risk.

Copy link
Contributor Author

@FrankLi123 FrankLi123 Aug 9, 2024

Choose a reason for hiding this comment

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

The url is a mock url used for the config test. Changed its value to https://0.0.0.0:9092/ for better view.

case "Create":
err := w.handleActivityPubCreate(ctx, activityPubTask.Message, activity)
if err != nil {
return nil, fmt.Errorf("error occured in handleActivityPubCreate")
Copy link
Contributor

@brucexc brucexc Jul 30, 2024

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("error occured in handleActivityPubCreate")
wrap the specific error
Consider changing to:
return nil, fmt.Errorf("error occurred in handleActivityPubCreate: %w", err)

Copy link
Contributor

Choose a reason for hiding this comment

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

and typo occured -> occcurred

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved.

return nil, fmt.Errorf("error occurred in handleActivityPubLike: %w", err)
}
default:
zap.L().Debug("unsupported type", zap.String("type", activityPubTask.Message.Type))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
zap.L().Debug("unsupported type", zap.String("type", activityPubTask.Message.Type))
using Info level instead of Debug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved.

if err != nil {
return nil, fmt.Errorf("error occured in handleActivityPubCreate")
}
case "Announce":
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
case "Announce":
using an enumeration is better.

Copy link
Contributor Author

@FrankLi123 FrankLi123 Aug 9, 2024

Choose a reason for hiding this comment

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

defined message types in the mastodon provider type file, and used the enumeration here


// Check if the Note is a reply to another post
// If true, then make it an activity SocialComment object
if parentID, ok := noteObject["inReplyTo"].(string); ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if parentID, ok := noteObject["inReplyTo"].(string); ok {
using constants for magic strings like "Note", "inReplyTo"

case network.ActivityPubSource:
instance.monitorClient, err = monitor.NewActivityPubClient(config.EndpointID, config.Parameters)
if err != nil {
return nil, fmt.Errorf("new arweave monitorClient: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("new arweave monitorClient: %w", err)
incorrect error info

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved.

@FrankLi123 FrankLi123 merged commit 749225c into feat/integrate-activitypub-mastodon-data-source Sep 13, 2024
5 checks passed
@FrankLi123 FrankLi123 deleted the feat/integrate-activitypub-mastodon-worker branch September 13, 2024 10:20
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