Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
import { trans } from 'laravel-vue-i18n';
import { toast } from 'vue-sonner';
import { useConnectChannelDialog } from '@/composables/useConnectChannelDialog';
import type { PostComposition } from '@/composables/usePostComposition';
import { useWorkspaceAbilities } from '@/composables/useWorkspaceAbilities';
import { PostStatus } from '@/types/post';
interface SaveAndLinkFacebookOptions {
/** The status the edited post had when it opened, if it was saved. */
status: () => string | undefined;
/** Whether the composer is set to publish now rather than at a time or in the queue. */
publishesNow: () => boolean;
/** Saves the post; false when it cannot be saved yet. */
submit: (status: PostComposition['status'], onSaved: () => void) => boolean;
}
/**
* Saves the post, then opens the step that reconnects an Instagram account
* through Facebook (music needs it). A scheduled post stays scheduled and a
* pending request stays pending; anything else is saved as a draft. An
* approver is asked to decide on a pending post first, so saving never
* approves it by accident.
*/
export const useSaveAndLinkFacebook = (options: SaveAndLinkFacebookOptions) => {
const { requiresApproval } = useWorkspaceAbilities();
const { openAt } = useConnectChannelDialog();
return (accountId: string): void => {
const status = options.status();
if (status === PostStatus.PendingApproval && !requiresApproval.value) {
toast.error(trans('posts.form.instagram.music.save_and_link_pending'), {
testId: 'instagram-music-save-and-link-pending',
});
return;
}
const keepsSchedule =
(status === PostStatus.Scheduled ||
status === PostStatus.PendingApproval) &&
!options.publishesNow();
const submitted = options.submit(
keepsSchedule ? PostStatus.Scheduled : PostStatus.Draft,
() => openAt('instagram-facebook', accountId),
);
if (!submitted) {
toast.error(trans('posts.form.instagram.music.save_and_link_blocked'), {
testId: 'instagram-music-save-and-link-blocked',
});
}
};
};