fix: X premium to upload longer videos
This commit is contained in:
parent
cde4e25c9d
commit
646caf5213
|
|
@ -413,7 +413,8 @@ export const AddEditModal: FC<{
|
|||
if (key.checkValidity) {
|
||||
const check = await key.checkValidity(
|
||||
key?.value.map((p: any) => p.image || []),
|
||||
key.settings
|
||||
key.settings,
|
||||
JSON.parse(key?.integration?.additionalSettings || '[]')
|
||||
);
|
||||
if (typeof check === 'string') {
|
||||
toaster.show(check, 'warning');
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ const finalInformation = {} as {
|
|||
path: string;
|
||||
}>
|
||||
>,
|
||||
settings: any
|
||||
settings: any,
|
||||
additionalSettings: any,
|
||||
) => Promise<string | true>;
|
||||
maximumCharacters?: number;
|
||||
};
|
||||
|
|
@ -45,7 +46,8 @@ export const useValues = (
|
|||
path: string;
|
||||
}>
|
||||
>,
|
||||
settings: any
|
||||
settings: any,
|
||||
additionalSettings: any,
|
||||
) => Promise<string | true>,
|
||||
maximumCharacters?: number
|
||||
) => {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,8 @@ export const withProvider = function <T extends object>(
|
|||
path: string;
|
||||
}>
|
||||
>,
|
||||
settings: T
|
||||
settings: T,
|
||||
additionalSettings: any,
|
||||
) => Promise<string | true>,
|
||||
maximumCharacters?: number | ((settings: any) => number)
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ export default withProvider(
|
|||
SettingsComponent,
|
||||
undefined,
|
||||
XDto,
|
||||
async (posts) => {
|
||||
async (posts, settings, additionalSettings: any) => {
|
||||
const premium = additionalSettings?.find((p: any) => p?.title === 'Verified')?.value || false;
|
||||
if (posts.some((p) => p.length > 4)) {
|
||||
return 'There can be maximum 4 pictures in a post.';
|
||||
}
|
||||
|
|
@ -74,7 +75,7 @@ export default withProvider(
|
|||
}
|
||||
for (const load of posts.flatMap((p) => p.flatMap((a) => a.path))) {
|
||||
if (load.indexOf('mp4') > -1) {
|
||||
const isValid = await checkVideoDuration(load);
|
||||
const isValid = await checkVideoDuration(load, premium);
|
||||
if (!isValid) {
|
||||
return 'Video duration must be less than or equal to 140 seconds.';
|
||||
}
|
||||
|
|
@ -89,7 +90,7 @@ export default withProvider(
|
|||
return 280;
|
||||
}
|
||||
);
|
||||
const checkVideoDuration = async (url: string): Promise<boolean> => {
|
||||
const checkVideoDuration = async (url: string, isPremium = false): Promise<boolean> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const video = document.createElement('video');
|
||||
video.src = url;
|
||||
|
|
@ -97,7 +98,7 @@ const checkVideoDuration = async (url: string): Promise<boolean> => {
|
|||
video.onloadedmetadata = () => {
|
||||
// Check if the duration is less than or equal to 140 seconds
|
||||
const duration = video.duration;
|
||||
if (duration <= 140) {
|
||||
if ((!isPremium && duration <= 140) || isPremium) {
|
||||
resolve(true); // Video duration is acceptable
|
||||
} else {
|
||||
resolve(false); // Video duration exceeds 140 seconds
|
||||
|
|
|
|||
Loading…
Reference in New Issue