-
Notifications
You must be signed in to change notification settings - Fork 5.5k
14336 aweber #18738
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
Open
luancazarine
wants to merge
4
commits into
master
Choose a base branch
from
14336-aweber
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+431
−116
Open
14336 aweber #18738
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5af1965
Enhance Aweber component with new actions and updates
luancazarine 76006bd
pnpm update
luancazarine 44b6eb2
Fix typos in Aweber component descriptions and property names
luancazarine 68a4918
Update readOnlyHint in create-broadcast action to allow editing
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
163 changes: 163 additions & 0 deletions
163
components/aweber/actions/create-broadcast/create-broadcast.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
import aweberApp from "../../aweber.app.mjs"; | ||
|
||
export default { | ||
key: "aweber-create-broadcast", | ||
name: "Create Broadcast", | ||
description: "Create a broadcast under the specified account and list. [See the docs here](https://api.aweber.com/#tag/Broadcasts/paths/~1accounts~1%7BaccountId%7D~1lists~1%7BlistId%7D~1broadcasts/post).", | ||
type: "action", | ||
version: "0.0.1", | ||
annotations: { | ||
destructiveHint: false, | ||
openWorldHint: true, | ||
readOnlyHint: false, | ||
}, | ||
props: { | ||
aweberApp, | ||
accountId: { | ||
propDefinition: [ | ||
aweberApp, | ||
"accountId", | ||
], | ||
}, | ||
listId: { | ||
propDefinition: [ | ||
aweberApp, | ||
"listId", | ||
({ accountId }) => ({ | ||
accountId, | ||
}), | ||
], | ||
}, | ||
bodyHTML: { | ||
type: "string", | ||
label: "Body HTML", | ||
description: "The content of the message in HTML format. If `Body Text` is not provided, it will be auto-generated. If `Body Text` is not provided, `Body HTML` must be provided.", | ||
}, | ||
bodyText: { | ||
type: "string", | ||
label: "Body Text", | ||
description: "The content of the message in plain text, used when HTML is not supported. If `Body HTML` is not provided, the broadcast will be sent using only the `Body Text`. If `Body Text` is not provided, `Body HTML` must be provided.", | ||
}, | ||
bodyAmp: { | ||
type: "string", | ||
label: "Body AMP", | ||
description: "The content of the message in AMP format. [Read Aweber KB article before using this field](https://help.aweber.com/hc/en-us/articles/360025741194)", | ||
optional: true, | ||
}, | ||
clickTrackingEnabled: { | ||
type: "boolean", | ||
label: "Click Tracking Enabled", | ||
description: "Enables links in the email message to be tracked.", | ||
optional: true, | ||
}, | ||
excludeLists: { | ||
propDefinition: [ | ||
aweberApp, | ||
"listSelfLink", | ||
({ accountId }) => ({ | ||
accountId, | ||
}), | ||
], | ||
type: "string[]", | ||
label: "Exclude Lists", | ||
description: "List of [Lists](https://api.aweber.com/#tag/Lists) URLs to exclude in the delivery of this broadcast. **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/lists/<list_id>`**", | ||
optional: true, | ||
}, | ||
includeLists: { | ||
propDefinition: [ | ||
aweberApp, | ||
"listSelfLink", | ||
({ accountId }) => ({ | ||
accountId, | ||
}), | ||
], | ||
type: "string[]", | ||
label: "Include Lists", | ||
description: "List of [Lists](https://api.aweber.com/#tag/Lists) URLs to include in the delivery of this broadcast. **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/lists/<list_id>`**", | ||
optional: true, | ||
}, | ||
facebookIntegration: { | ||
propDefinition: [ | ||
aweberApp, | ||
"integrations", | ||
({ accountId }) => ({ | ||
accountId, | ||
serviceName: "facebook", | ||
}), | ||
], | ||
label: "Facebook Integration", | ||
description: "URL to the [Facebook broadcast integration](https://api.aweber.com/#tag/Integrations) to use for this broadcast. When the broadcast is sent, the subject of the broadcast will be posted to this Facebook integration - **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/integrations/<integration_id>`**.", | ||
optional: true, | ||
}, | ||
isArchived: { | ||
type: "boolean", | ||
label: "Is Archived", | ||
description: "Whether the broadcast enabled sharing via an archive URL.", | ||
optional: true, | ||
}, | ||
notifyOnSend: { | ||
type: "boolean", | ||
label: "Notify on Send", | ||
description: "If true, notify when stats are available on a sent broadcast message.", | ||
optional: true, | ||
}, | ||
segmentLink: { | ||
propDefinition: [ | ||
aweberApp, | ||
"segmentSelfLink", | ||
({ | ||
accountId, listId, | ||
}) => ({ | ||
accountId, | ||
listId, | ||
}), | ||
], | ||
optional: true, | ||
}, | ||
subject: { | ||
type: "string", | ||
label: "Subject", | ||
description: "The broadcast subject line. Subject must not be empty nor contain only whitespace.", | ||
}, | ||
twitterIntegration: { | ||
propDefinition: [ | ||
aweberApp, | ||
"integrations", | ||
({ accountId }) => ({ | ||
accountId, | ||
serviceName: "twitter", | ||
}), | ||
], | ||
label: "Twitter Integration", | ||
description: "URL to the [Twitter broadcast integration](https://api.aweber.com/#tag/Integrations) to use for this broadcast. When the broadcast is sent, the subject of the broadcast will be tweeted - **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/integrations/<integration_id>`**.", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.aweberApp.createBroadcast({ | ||
$, | ||
accountId: this.accountId, | ||
listId: this.listId, | ||
data: { | ||
body_html: this.bodyHTML, | ||
body_text: this.bodyText, | ||
body_amp: this.bodyAmp, | ||
click_tracking_enabled: this.clickTrackingEnabled, | ||
exclude_lists: this.excludeLists, | ||
include_lists: this.includeLists, | ||
facebook_integration: this.facebookIntegration, | ||
is_archived: this.isArchived, | ||
notify_on_send: this.notifyOnSend, | ||
segment_link: this.segmentLink, | ||
subject: this.subject, | ||
twitter_integration: this.twitterIntegration, | ||
}, | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded", | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
$.export("$summary", `Successfully created broadcast with **UUID: ${response.uuid}**.`); | ||
return response; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prop requirements contradict descriptions.
Both
bodyHTML
andbodyText
are required fields (nooptional: true
), but their descriptions indicate that at least one should be provided, not both. This prevents users from creating HTML-only or text-only broadcasts as described in the prop documentation.Apply this diff to make both props optional while enforcing that at least one must be provided:
Then add validation in the
run
method before the API call:📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeRabbit's comment makes sense here.
bodyHTML
andbodyText
are both required, but their descriptions somewhat contradict this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GTFalcao, thank you for confirming! Yes, the current implementation creates a conflict between the required fields and their descriptions. Making both
bodyHTML
andbodyText
optional while adding runtime validation to ensure at least one is provided is the correct approach. This will allow users to create:while preventing the error case where neither is provided. The suggested fix aligns with the AWeber API behavior described in the prop documentation.