Skip to content

Conversation

jkmassel
Copy link
Contributor

Adds the WP.com Freshly Pressed endpoints for integration into Reader.

@jkmassel jkmassel requested a review from oguzkocer September 10, 2025 18:57
@jkmassel jkmassel self-assigned this Sep 10, 2025
Handles cases like:

- Valid u64
- `null`
- -1 (used in some cases in place of `null`)
- `false` (used in some cases in place of `null`)
Copy link
Contributor

@oguzkocer oguzkocer left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @jkmassel! I've left a few comments.

}

#[derive(Debug, Serialize, Deserialize, uniffi::Record)]
pub struct FreshlyPressedDiscussionSettings {
Copy link
Contributor

Choose a reason for hiding this comment

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

If I am not mistaken, a discussion field needs to be added to FreshlyPressedPost and use this struct. At least, the sample json used in tests seem to include it.

}

#[derive(Debug, Serialize, Deserialize, uniffi::Record)]
pub struct FreshlyPressedEditorialSettings {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be unused.

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, all endpoint files have an _endpoint suffix, which this file should also follow.

pub struct FreshlyPressedPost {
#[serde(rename = "ID")]
pub id: PostId,
#[serde(alias = "site_ID")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless we specifically need to alias, we should be consistent and use rename everywhere.

Comment on lines +238 to +271
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, IntoStaticStr)]
enum FreshlyPressedListParamsField {
#[strum(serialize = "number")]
Number,
#[strum(serialize = "page")]
Page,
}

impl AppendUrlQueryPairs for FreshlyPressedListParams {
fn append_query_pairs(&self, query_pairs_mut: &mut QueryPairs) {
query_pairs_mut
.append_option_query_value_pair(
FreshlyPressedListParamsField::Number,
self.number.as_ref(),
)
.append_option_query_value_pair(
FreshlyPressedListParamsField::Page,
self.page.as_ref(),
);
}
}

impl FromUrlQueryPairs for FreshlyPressedListParams {
fn from_url_query_pairs(query_pairs: UrlQueryPairsMap) -> Option<Self> {
Some(Self {
number: query_pairs.get(FreshlyPressedListParamsField::Number),
page: query_pairs.get(FreshlyPressedListParamsField::Page),
})
}

fn supports_pagination() -> bool {
true
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These should no longer be necessary and should be replaced with the new macros you've reviewed yesterday.

}

#[derive(Debug, Serialize, Deserialize, uniffi::Record)]
pub struct FreshlyPressedPost {
Copy link

Choose a reason for hiding this comment

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

"Freshly Pressed" seemingly uses the same response format as all other response streams in Reader: site, tags, feeds, discover. I suggest generalizing it from the start even if we don't end up using it everywhere originally.

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.

3 participants