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

add support for edit_current_application endpoint #3035

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Conversation

ivinjabraham
Copy link
Contributor

@ivinjabraham ivinjabraham commented Nov 13, 2024

Fixes #2977

This PR depends on #3041, please merge that first.

@github-actions github-actions bot added the http Related to the `http` module. label Nov 13, 2024
Copy link
Member

@jamesbt365 jamesbt365 left a comment

Choose a reason for hiding this comment

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

Use the provided to_vec function instead of importing it from serde_json.

@jamesbt365
Copy link
Member

Also you haven't added anything but the low level http interface? Http usually shouldn't be directly used and you should probably add a builder like how our other stuff interacts with http.

@ivinjabraham
Copy link
Contributor Author

Use the provided to_vec function instead of importing it from serde_json.

Pesky auto-import. Should be fixed now.

Also you haven't added anything but the low level http interface? Http usually shouldn't be directly used and you should probably add a builder like how our other stuff interacts with http.

Right, so I'll make a edit_current_application_info.rs and impl Builder along with the required structs and methods?

@ivinjabraham
Copy link
Contributor Author

ivinjabraham commented Nov 15, 2024

It seems the CurrentApplicationInfo struct is out of date. There are few fields such as event_webhook_url and event_webhook_status that are missing. I'll send in a PR for that first.

Doc for reference

@github-actions github-actions bot added the model Related to the `model` module. label Nov 17, 2024
@github-actions github-actions bot added the builder Related to the `builder` module. label Nov 17, 2024
Copy link
Member

@jamesbt365 jamesbt365 left a comment

Choose a reason for hiding this comment

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

edit_current_appllication_info.rs -> edit_current_application_info.rs

@ivinjabraham ivinjabraham marked this pull request as ready for review November 18, 2024 03:43
Comment on lines 50 to 54
/// Interactions endpoint URL for the app.
///
/// To update an Interactions endpoint URL via the API, the URL must be valid according
/// to the [Receiving an Interaction]
/// (https://discord.com/developers/docs/interactions/receiving-and-responding#receiving-an-interaction) documentation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

These docs are private and therefore unnecessary. I'd recommend instead incorporating them into the docs for the methods themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, of course. Fixed it now.

Comment on lines -52 to +97
pub terms_of_service_url: Option<FixedString>,
pub bot: User,
#[serde(default)]
pub privacy_policy_url: Option<FixedString>,
pub owner: Option<User>,
// omitted `summary` because it deprecated
pub verify_key: FixedString,
pub terms_of_service_url: Option<String>,
#[serde(default)]
pub privacy_policy_url: Option<String>,
#[serde(default)]
pub owner: User,
pub verify_key: String,
pub team: Option<Team>,
#[serde(default)]
pub guild_id: Option<GuildId>,
#[serde(default)]
pub guild: Option<PartialGuild>,
#[serde(default)]
pub primary_sku_id: Option<SkuId>,
#[serde(default)]
pub slug: Option<FixedString>,
pub slug: String,
#[serde(default)]
pub cover_image: Option<FixedString>,
pub cover_image: String,
#[serde(default)]
pub flags: Option<ApplicationFlags>,
#[serde(default)]
pub tags: Option<Vec<String>>,
pub approximate_guild_count: Option<u32>,
#[serde(default)]
pub install_params: Option<InstallParams>,
pub approximate_user_install_count: Option<u32>,
#[serde(default)]
pub redirect_uris: Vec<String>,
#[serde(default)]
pub custom_install_url: Option<FixedString>,
pub interactions_endpoint_url: Option<String>,
/// The application's role connection verification entry point, which when configured will
/// render the app as a verification method in the guild role verification configuration.
pub role_connections_verification_url: Option<FixedString>,
#[serde(default)]
pub role_connections_verification_url: Option<String>,
#[serde(default)]
pub event_webhooks_url: Option<String>,
pub event_webhook_status: EventWebhookStatus,
#[serde(default)]
pub event_webhook_type: Vec<EventWebhookType>,
#[serde(default)]
pub tags: Option<Vec<String>>,
#[serde(default)]
pub install_params: Option<InstallParams>,
#[serde(default)]
pub integration_types_config: HashMap<InstallationContext, InstallationContextConfig>,
pub approximate_guild_count: Option<u32>,
pub approximate_user_install_count: Option<u32>,
pub guild: Option<PartialGuild>,
pub redirect_uris: Option<Vec<String>>,
pub interactions_endpoint_url: Option<String>,
#[serde(default)]
pub custom_install_url: String,
Copy link
Member

Choose a reason for hiding this comment

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

You have replaced a bunch of FixedString here with String, I'm assuming it's just a leftover from when this PR targeted current, can you change it back to use FixedString (for performance reasons).

Comment on lines +306 to +323
impl InstallParams {
#[must_use]
pub fn new() -> Self {
Self::default()
}

#[must_use]
pub fn scopes(mut self, scopes: Vec<Scope>) -> Self {
self.scopes = FixedArray::from_vec_trunc(scopes);
self
}

#[must_use]
pub fn permissions(mut self, permissions: Permissions) -> Self {
self.permissions = permissions;
self
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Please make this an CreateInstallParams in the new module to avoid mixing memory-optimised (FixedArray) and compute-optimised (Vec) types. This would also allow for new to take both the required fields, scopes and permissions.

Comment on lines +92 to +109
pub fn icon(mut self, hash: &str) -> Self {
if let Ok(image_hash) = hash.parse() {
self.icon = Some(image_hash);
} else {
println!("Error parsing image hash while constructing EditCurrentApplicationInfo");
}
self
}

/// Default rich presence invite cover image for the app.
pub fn cover_image(mut self, hash: &str) -> Self {
if let Ok(image_hash) = hash.parse() {
self.cover_image = Some(image_hash);
} else {
println!("Error parsing image hash while constructing EditCurrentApplicationInfo");
}
self
}
Copy link
Member

Choose a reason for hiding this comment

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

  1. Please don't take types just to parse them into different types.
  2. Please don't print on the user's behalf.
  3. This is meant to be base64 image data, not an image hash, as the docs say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builder Related to the `builder` module. http Related to the `http` module. model Related to the `model` module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing endpoint: Edit Current Application
4 participants