Skip to content

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

fix(gmb): fail post when Google returns REJECTED or unconfirmed localPost

Gilad Resisif700b8a1170d
diff --git a/libraries/nestjs-libraries/src/integrations/social/gmb.provider.ts b/libraries/nestjs-libraries/src/integrations/social/gmb.provider.ts
index 9d3bdc6e1..40e0c21f9 100644
--- a/libraries/nestjs-libraries/src/integrations/social/gmb.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/gmb.provider.ts
@@ -9,6 +9,7 @@ import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
import { google } from 'googleapis';
import { OAuth2Client } from 'google-auth-library/build/src/auth/oauth2client';
import {
+ BadBody,
SocialAbstract,
ValidityMedia,
} from '@gitroom/nestjs-libraries/integrations/social.abstract';
@@ -485,8 +486,26 @@ export class GmbProvider extends SocialAbstract implements SocialProvider {
const postData = await response.json();
+ if (postData?.state === 'REJECTED') {
+ throw new BadBody(
+ this.identifier,
+ JSON.stringify(postData),
+ JSON.stringify(postBody),
+ 'Google rejected this post for a content policy violation. Please review the post content and try again.'
+ );
+ }
+
+ if (!postData?.name) {
+ throw new BadBody(
+ this.identifier,
+ JSON.stringify(postData),
+ JSON.stringify(postBody),
+ 'Google did not confirm the post creation. Please try again.'
+ );
+ }
+
// Extract the post ID and construct the URL
- const postId = postData.name || '';
+ const postId = postData.name;
const locationId = id.split('/').pop();
// GMB posts don't have direct URLs, but we can link to the business profile