Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

fix(vk): surface VK API errors from the media upload calls

Gilad Resisib757cdf007d2
diff --git a/libraries/nestjs-libraries/src/integrations/social/vk.provider.ts b/libraries/nestjs-libraries/src/integrations/social/vk.provider.ts
index 25adc2fd6..c3eaff83e 100644
--- a/libraries/nestjs-libraries/src/integrations/social/vk.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/vk.provider.ts
@@ -177,6 +177,7 @@ export class VkProvider extends SocialAbstract implements SocialProvider {
: `https://api.vk.com/method/photos.getWallUploadServer?owner_id=${userId}&access_token=${accessToken}&v=5.251`
)
).json();
+ this.checkApiError(all);
const { data } = await this.getSsrfSafeAxios().get(media.path!, {
responseType: 'stream',
@@ -213,17 +214,17 @@ export class VkProvider extends SocialAbstract implements SocialProvider {
formSend.append('server', value.server);
formSend.append('hash', value.hash);
- const { id } = (
- await (
- await fetch(
- `https://api.vk.com/method/photos.saveWallPhoto?access_token=${accessToken}&v=5.251`,
- {
- method: 'POST',
- body: formSend,
- }
- )
- ).json()
- ).response[0];
+ const saved = await (
+ await fetch(
+ `https://api.vk.com/method/photos.saveWallPhoto?access_token=${accessToken}&v=5.251`,
+ {
+ method: 'POST',
+ body: formSend,
+ }
+ )
+ ).json();
+ this.checkApiError(saved);
+ const { id } = saved.response[0];
return {
id,