Skip to content
Open
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
5 changes: 2 additions & 3 deletions packages/public-api/src/apis/reddit/models/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ export type SubmitMediaOptions = CommonSubmitPostOptions & {
// If `kind` is "video" or "videogif" this must be set to the thumbnail URL
// https://www.reddit.com/dev/api/#POST_api_submit
videoPosterUrl?: string;
// If `kind` is "image" this must be set to the image URL
// Currently Devvit only supports posts with a single image
imageUrls?: [string];
// If multiple image URLs are supplied (2-20) Reddit will automatically create a gallery post.
imageUrls?: string[];
Copy link
Contributor

Choose a reason for hiding this comment

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

sadly, multiple images are unsupported on the backend:

if len(req.GetImageUrls().GetValues()) != 1 {
	return nil, status.Error(codes.Unimplemented, "only posts with a single image are allowed")
}

Copy link

Choose a reason for hiding this comment

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

To heck with it all then I'm glad you got a job

Copy link

Choose a reason for hiding this comment

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

Poll - Which humanoid robot from CES 2026 is the most promising_.png

Copy link

Choose a reason for hiding this comment

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

  • #### @

};

export type SubmitSelfPostOptions = PostTextOptions & CommonSubmitPostOptions;
Expand Down
48 changes: 48 additions & 0 deletions packages/public-api/src/apis/reddit/tests/post.api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,55 @@ describe('Post API', () => {
);
});
});
test('submit(): can create gallery post with multiple images', async () => {
const { reddit, metadata } = createTestRedditApiClient();
const mockedPost = new Post(
{
...defaultPostData,
gallery: [
{
url: 'https://example.com/1.jpg',
width: 1080,
height: 1080,
status: GalleryMediaStatus.VALID,
},
{
url: 'https://example.com/2.jpg',
width: 1080,
height: 1080,
status: GalleryMediaStatus.VALID,
},
],
},
metadata
);

const spyPlugin = vi.spyOn(Devvit.redditAPIPlugins.LinksAndComments, 'Submit');
spyPlugin.mockImplementationOnce(async () => ({
json: { data: { id: 'post' }, errors: [] },
}));

vi.spyOn(Post, 'getById').mockResolvedValueOnce(mockedPost);

const imageUrls = ['https://example.com/1.jpg', 'https://example.com/2.jpg'];

await reddit.submitPost({
title: 'My Gallery Post',
subredditName: 'askReddit',
kind: 'image',
imageUrls,
});

expect(spyPlugin).toHaveBeenCalledWith(
expect.objectContaining({
kind: 'image',
imageUrls,

}),
metadata
);
});
});
describe('setTextFallback()', () => {
test('throws error if no fallback was set', async () => {
const { metadata } = createTestRedditApiClient();
Expand Down