Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/providers/lemmyv0/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ import { InvalidPayloadError } from "../../errors";
import { cleanThreadiverseParams } from "../../helpers";
import * as types from "../../types";

export function fromListingType(
type_?: types.ListingType,
): LemmyV0.ListingType | undefined {
export function fromListingType(type_?: types.ListingType) {
if (!type_) return undefined;
const map: Record<types.ListingType, LemmyV0.ListingType> = {
const map = {
all: "All",
local: "Local",
moderator_view: "ModeratorView",
subscribed: "Subscribed",
};
} as const satisfies Record<types.ListingType, LemmyV0.ListingType>;
return map[type_];
}

Expand Down
3 changes: 2 additions & 1 deletion src/providers/piefed/README
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
npx openapi-typescript https://freamon.github.io/piefed-api/swagger.yaml --output src/providers/piefed/schema.ts
curl -s https://piefed.social/api/alpha/swagger.json -o /tmp/piefed-swagger.json
npx openapi-typescript /tmp/piefed-swagger.json --output src/providers/piefed/schema.ts
11 changes: 1 addition & 10 deletions src/providers/piefed/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ type PiefedPost = components["schemas"]["Post"];
type PiefedPostAggregates = components["schemas"]["PostAggregates"];
type PiefedPrivateMessage = components["schemas"]["PrivateMessage"];

export function fromListingType(
listingType: types.ListingType | undefined,
):
| "All"
| "Local"
| "Moderating"
| "ModeratorView"
| "Popular"
| "Subscribed"
| undefined {
export function fromListingType(listingType: types.ListingType | undefined) {
switch (listingType) {
case "all":
return "All";
Expand Down
14 changes: 10 additions & 4 deletions src/providers/piefed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class UnsafePiefedClient implements BaseClient {
): ReturnType<BaseClient["createPostReport"]> {
await this.#client.POST("/api/alpha/post/report", {
...options,
body: { ...payload },
body: { ...payload, report_remote: true },
});
}

Expand Down Expand Up @@ -306,7 +306,11 @@ export class UnsafePiefedClient implements BaseClient {
): Promise<{ post_view: PostView }> {
const response = await this.#client.POST("/api/alpha/post/feature", {
...options,
body: { ...payload },
body: {
...payload,
feature_type:
payload.feature_type === "community" ? "Community" : "Local",
},
});

return {
Expand Down Expand Up @@ -640,8 +644,10 @@ export class UnsafePiefedClient implements BaseClient {
const { type_, ...rest } = compat.fromPageParams(payload);
const response = await this.#client.GET("/api/alpha/community/list", {
...options,
// @ts-expect-error TODO: fix this
params: { query: { ...rest, type_: compat.fromListingType(type_) } },
params: {
// @ts-expect-error `sort` from the unioned payload type leaks v1 values (e.g. "comments") that piefed doesn't accept
query: { ...rest, type_: compat.fromListingType(type_) },
},
});

return {
Expand Down
Loading
Loading