-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Development has been made to allow X users to generate and use their own APIKEY and Access Token #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Development has been made to allow X users to generate and use their own APIKEY and Access Token #489
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { withProvider } from '@gitroom/frontend/components/launches/providers/high.order.provider'; | ||
export default withProvider( | ||
null, | ||
undefined, | ||
undefined, | ||
async (posts) => { | ||
if (posts.some((p) => p.length > 4)) { | ||
return 'There can be maximum 4 pictures in a post.'; | ||
} | ||
|
||
if ( | ||
posts.some( | ||
(p) => p.some((m) => m.path.indexOf('mp4') > -1) && p.length > 1 | ||
) | ||
) { | ||
return 'There can be maximum 1 video in a post.'; | ||
} | ||
|
||
for (const load of posts.flatMap((p) => p.flatMap((a) => a.path))) { | ||
if (load.indexOf('mp4') > -1) { | ||
const isValid = await checkVideoDuration(load); | ||
if (!isValid) { | ||
return 'Video duration must be less than or equal to 140 seconds.'; | ||
} | ||
} | ||
} | ||
Comment on lines
+19
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle potential CORS issues when accessing video metadata Accessing |
||
return true; | ||
}, | ||
280 | ||
); | ||
|
||
const checkVideoDuration = async (url: string): Promise<boolean> => { | ||
return new Promise((resolve, reject) => { | ||
const video = document.createElement('video'); | ||
video.src = url; | ||
video.preload = 'metadata'; | ||
|
||
video.onloadedmetadata = () => { | ||
// Check if the duration is less than or equal to 140 seconds | ||
const duration = video.duration; | ||
if (duration <= 140) { | ||
resolve(true); // Video duration is acceptable | ||
} else { | ||
resolve(false); // Video duration exceeds 140 seconds | ||
} | ||
}; | ||
|
||
video.onerror = () => { | ||
reject(new Error('Failed to load video metadata.')); | ||
}; | ||
}); | ||
}; | ||
Comment on lines
+32
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure proper error handling in The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve media type detection and validation logic
Using
indexOf('mp4')
to detect media types may produce false positives and is not reliable. Consider using file extensions withendsWith('.mp4')
or checking MIME types. Also, clarify the validation logic to ensure that posts containing a video do not include other media items.Apply this diff to improve media type checking and validation logic:
📝 Committable suggestion