feat: facebook textpost embedded url
This commit is contained in:
parent
3519889bc1
commit
f780304a9d
|
|
@ -412,6 +412,8 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
|
|||
? 'Create output'
|
||||
: !existingData?.integration
|
||||
? t('add_to_calendar', 'Add to calendar')
|
||||
: existingData?.posts?.[0]?.state === 'DRAFT'
|
||||
? t('schedule', 'Schedule')
|
||||
: t('update', 'Update')}
|
||||
</div>
|
||||
{!dummy && (
|
||||
|
|
|
|||
|
|
@ -4,12 +4,29 @@ import {
|
|||
PostComment,
|
||||
withProvider,
|
||||
} from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
|
||||
import { FacebookDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/facebook.dto';
|
||||
import { Input } from '@gitroom/react/form/input';
|
||||
import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values';
|
||||
|
||||
export const FacebookSettings = () => {
|
||||
const { register } = useSettings();
|
||||
|
||||
return (
|
||||
<Input
|
||||
label={
|
||||
'Embedded URL (only for text Post)'
|
||||
}
|
||||
{...register('url')}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default withProvider({
|
||||
postComment: PostComment.COMMENT,
|
||||
minimumCharacters: [],
|
||||
SettingsComponent: null,
|
||||
SettingsComponent: FacebookSettings,
|
||||
CustomPreviewComponent: undefined,
|
||||
dto: undefined,
|
||||
dto: FacebookDto,
|
||||
checkValidity: undefined,
|
||||
maximumCharacters: 63206,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
import { IsOptional, ValidateIf, IsUrl } from 'class-validator';
|
||||
|
||||
export class FacebookDto {
|
||||
@IsOptional()
|
||||
@ValidateIf(p => p.url)
|
||||
@IsUrl()
|
||||
url?: string;
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import {
|
|||
import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
|
||||
import dayjs from 'dayjs';
|
||||
import { SocialAbstract } from '@gitroom/nestjs-libraries/integrations/social.abstract';
|
||||
import { FacebookDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/facebook.dto';
|
||||
|
||||
export class FacebookProvider extends SocialAbstract implements SocialProvider {
|
||||
identifier = 'facebook';
|
||||
|
|
@ -22,10 +23,12 @@ export class FacebookProvider extends SocialAbstract implements SocialProvider {
|
|||
'read_insights',
|
||||
];
|
||||
|
||||
override handleErrors(body: string): {
|
||||
type: 'refresh-token' | 'bad-body';
|
||||
value: string;
|
||||
} | undefined {
|
||||
override handleErrors(body: string):
|
||||
| {
|
||||
type: 'refresh-token' | 'bad-body';
|
||||
value: string;
|
||||
}
|
||||
| undefined {
|
||||
// Access token validation errors - require re-authentication
|
||||
if (body.indexOf('Error validating access token') > -1) {
|
||||
return {
|
||||
|
|
@ -274,7 +277,7 @@ export class FacebookProvider extends SocialAbstract implements SocialProvider {
|
|||
async post(
|
||||
id: string,
|
||||
accessToken: string,
|
||||
postDetails: PostDetails[]
|
||||
postDetails: PostDetails<FacebookDto>[]
|
||||
): Promise<PostResponse[]> {
|
||||
const [firstPost, ...comments] = postDetails;
|
||||
|
||||
|
|
@ -345,6 +348,9 @@ export class FacebookProvider extends SocialAbstract implements SocialProvider {
|
|||
},
|
||||
body: JSON.stringify({
|
||||
...(uploadPhotos?.length ? { attached_media: uploadPhotos } : {}),
|
||||
...(firstPost?.settings?.url
|
||||
? { link: firstPost.settings.url }
|
||||
: {}),
|
||||
message: firstPost.message,
|
||||
published: true,
|
||||
}),
|
||||
|
|
|
|||
Loading…
Reference in New Issue