nicolium: add a check for meaningless descriptions

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-03-21 12:57:53 +01:00
parent b391f01452
commit f2e0e1935d
2 changed files with 26 additions and 7 deletions

View File

@ -478,10 +478,18 @@ const ReblogButton: React.FC<IReblogButton> = ({
const handleReblogClick: React.EventHandler<React.MouseEvent> = (e) => {
if (me) {
const hasMissingDescriptions = status.media_attachments.some(
(attachment) => attachment.type !== 'unknown' && !attachment.description,
const attachments = status.media_attachments.filter(
(attachment) => attachment.type !== 'unknown',
);
const hasMissingDescriptions = attachments.some((attachment) => !attachment.description);
const hasFilenameDescriptions = attachments.some((attachment) => {
const extension = (attachment.remote_url || attachment.url).split('.').pop()?.toLowerCase();
return attachment.description.trim().endsWith(`.${extension}`);
});
const doReblog = () => {
if (status.reblogged) {
unreblogStatus();
@ -494,7 +502,7 @@ const ReblogButton: React.FC<IReblogButton> = ({
}
};
if (missingDescriptionBoostModal && hasMissingDescriptions) {
if (missingDescriptionBoostModal && (hasMissingDescriptions || hasFilenameDescriptions)) {
openModal('CONFIRM', {
heading: (
<FormattedMessage
@ -503,10 +511,20 @@ const ReblogButton: React.FC<IReblogButton> = ({
/>
),
message: (
<FormattedMessage
id='confirmations.boost_missing_description.message'
defaultMessage='The post does not have a description for all attachments. Do you want to repost it anyway?'
/>
<>
{hasMissingDescriptions && (
<FormattedMessage
id='confirmations.boost_missing_description.message'
defaultMessage='The post does not have a description for all attachments. Do you want to repost it anyway?'
/>
)}
{hasFilenameDescriptions && (
<FormattedMessage
id='confirmations.boost_missing_description.filename_warning'
defaultMessage="One or more attachments likely has a filename (e.g. 'image.jpg') as its description instead of meaningful alt text. Do you want to repost it anyway?"
/>
)}
</>
),
confirm: intl.formatMessage(messages.boostConfirm),
onConfirm: doReblog,

View File

@ -730,6 +730,7 @@
"confirmations.block_from_group.heading": "Ban from group",
"confirmations.block_from_group.message": "Are you sure you want to ban @{name} from the group?",
"confirmations.boost_missing_description.confirm": "Repost anyway",
"confirmations.boost_missing_description.filename_warning": "One or more attachments likely has a filename (e.g. 'image.jpg') as its description instead of meaningful alt text. Do you want to repost it anyway?",
"confirmations.boost_missing_description.heading": "Reposting a post with missing description",
"confirmations.boost_missing_description.message": "The post does not have a description for all attachments. Do you want to repost it anyway?",
"confirmations.cancel.confirm": "Discard",