Use same intervention flag text in send and view

This commit is contained in:
N-Pex 2025-09-29 11:24:06 +02:00
parent ed4991a5b1
commit b022e2f800
6 changed files with 78 additions and 66 deletions

View file

@ -507,8 +507,6 @@
"captured_with_camera": "Captured with a real camera. ",
"captured_screenshot": "Screenshot. ",
"captured_screenshot_ago": "Screenshot captured {ago} ago. ",
"generated_with_ai": "Generated with AI. ",
"generated_with_ai_ago": "Generated with AI {ago} ago. ",
"old_photo": "Photo older than 3 months. ",
"cc_source": "Source",
"cc_capture_timestamp": "Capture Timestamp",
@ -531,6 +529,6 @@
"screenshot_probably": "Image looks like a screenshot.",
"generated_with_ai": "Generated with AI.",
"modified": "Modified.",
"older_than_n_months": "Older than {n} months"
"older_than_n_months": "Older than {n} months."
}
}

View file

@ -294,8 +294,6 @@
"screenshot": "Seat scáileáin. ",
"captured_screenshot": "Seat scáileáin ",
"captured_screenshot_ago": "Gabhadh an seat scáileáin {ago} ó shin. ",
"generated_with_ai": "Gineadh le hintleacht shaorga. ",
"generated_with_ai_ago": "Gineadh le hintleacht shaorga {ago} ó shin. ",
"cc_source": "Foinse",
"cc_capture_timestamp": "Gabháil Stampa Ama",
"cc_location": "Suíomh"
@ -516,6 +514,7 @@
"cc": {
"content_credentials": "Dintiúir Ábhair",
"content_credentials_info": "Tá faisnéis foinse nó staire ar fáil le go bhféadfaidh an meán seo a fhíorú.",
"metadata-stripped": "Tá an íomhá comhbhrúite agus na meiteashonraí bainte díot.\n\nCreidimid go bhfuil faisnéis bhreise faoin gcomhad san íomhá seo. Más mian leat tuilleadh eolais a fháil, iarr ar an seoltóir an bunleagan a roinnt."
"metadata-stripped": "Tá an íomhá comhbhrúite agus na meiteashonraí bainte díot.\n\nCreidimid go bhfuil faisnéis bhreise faoin gcomhad san íomhá seo. Más mian leat tuilleadh eolais a fháil, iarr ar an seoltóir an bunleagan a roinnt.",
"generated_with_ai": "Gineadh le hintleacht shaorga. "
}
}

View file

@ -1,7 +1,5 @@
<template>
<div class="cc-detail-info" v-if="infoText !== undefined">
{{ infoText }}
</div>
<div class="cc-detail-info" v-if="infoText !== undefined" v-html="infoText" />
<div class="attachment-info__detail-box">
<div class="detail-title">
{{ t("cc.details") }}
@ -38,6 +36,7 @@ import { computed, ref, Ref, watch } from "vue";
import dayjs from "dayjs";
import CCProperty, { CCPropertyProps } from "./CCProperty.vue";
import relativeTime from "dayjs/plugin/relativeTime";
import { interventionText } from "./intervention";
dayjs.extend(relativeTime);
@ -162,26 +161,7 @@ watch(
creationDate.value = date.format("lll");
}
let result = "";
if (props.flags.generator === "camera") {
result += t("file_mode.captured_with_camera");
} else if (props.flags.generator === "screenshot") {
if (date) {
result += t("file_mode.captured_screenshot_ago", { ago: date.fromNow(true) });
} else {
result += t("file_mode.captured_screenshot");
}
} else if (props.flags.generator === "ai") {
if (date) {
result += t("file_mode.generated_with_ai_ago", { ago: date.fromNow(true) });
} else {
result += t("file_mode.generated_with_ai");
}
}
if (date && dayjs().diff(date, "month") >= 3) {
result += t("file_mode.old_photo");
}
infoText.value = result === "" ? undefined : result;
infoText.value = interventionText(t, props.flags);
}
} catch (error) { }

View file

@ -10,8 +10,8 @@
<script setup lang="ts">
import { computed } from "vue";
import { ProofHintFlags } from "../../models/proof";
import dayjs from "dayjs";
import { useI18n } from "vue-i18n";
import { interventionText } from "./intervention";
const { t } = useI18n()
@ -31,41 +31,7 @@ const showCheck = computed(() => {
const infoText = computed(() => {
if (!multiple && flags.length == 1) {
const f = flags[0];
let res = "";
if (f.generator !== "unknown" && f.generatorSource === "c2pa") {
if (f.generator === "camera") {
res += "<b>" + t("cc.captured_with_camera") + "</b> ";
} else if (f.generator === "screenshot") {
res += "<b>" + t("cc.screenshot") + "</b> ";
} else if (f.generator === "ai") {
res += "<b>" + t("cc.generated_with_ai") + "</b> ";
}
if ((f.edits?.length ?? 0) > 0) {
res += "<b>" + t("cc.modified") + "</b> ";
}
if (f.creationDate && dayjs().diff(f.creationDate, "month") >= 3) {
res += "<b>" + t("cc.older_than_n_months", {n: 3}) + "</b> ";
}
return res;
} else if (f.generator !== "unknown") {
if (f.generator === "camera") {
res += "<b>" + t("cc.captured_with_camera") + "</b> ";
} else if (f.generator === "screenshot") {
res += "<b>" + t("cc.screenshot_probably") + "</b> ";
return res;
} else if (f.generator === "ai") {
res += "<b>" + t("cc.generated_with_ai") + "</b> ";
}
if ((f.edits?.length ?? 0) > 0) {
res += "<b>" + t("cc.modified") + "</b> ";
}
if (f.creationDate && dayjs().diff(f.creationDate, "month") >= 3) {
res += "<b>" + t("cc.older_than_n_months", {n: 3}) + "</b> ";
}
return res;
}
return interventionText(t, flags[0]);
} else if (multiple && flags.length >= 1) {
const modifiedMedia = flags.some((f) => f.edits?.length);
const aiGeneratedMedia = flags.some((f) => f.generator === "ai");

View file

@ -0,0 +1,45 @@
import { ProofHintFlags } from "../../models/proof";
import dayjs from "dayjs";
export const interventionText = (
t: any,
f: ProofHintFlags
): string | undefined => {
let res = "";
if (f.generator !== "unknown" && f.generatorSource === "c2pa") {
if (f.generator === "camera") {
res += "<b>" + t("cc.captured_with_camera") + "</b> ";
} else if (f.generator === "screenshot") {
res += "<b>" + t("cc.screenshot") + "</b> ";
} else if (f.generator === "ai") {
res += "<b>" + t("cc.generated_with_ai") + "</b> ";
}
if ((f.edits?.length ?? 0) > 0) {
res += "<b>" + t("cc.modified") + "</b> ";
}
if (f.creationDate && dayjs().diff(f.creationDate, "month") >= 3) {
res += "<b>" + t("cc.older_than_n_months", { n: 3 }) + "</b> ";
}
if (res === "") return undefined;
return res;
} else if (f.generator !== "unknown") {
if (f.generator === "camera") {
res += "<b>" + t("cc.captured_with_camera") + "</b> ";
} else if (f.generator === "screenshot") {
res += "<b>" + t("cc.screenshot_probably") + "</b> ";
return res;
} else if (f.generator === "ai") {
res += "<b>" + t("cc.generated_with_ai") + "</b> ";
}
if ((f.edits?.length ?? 0) > 0) {
res += "<b>" + t("cc.modified") + "</b> ";
}
if (f.creationDate && dayjs().diff(f.creationDate, "month") >= 3) {
res += "<b>" + t("cc.older_than_n_months", { n: 3 }) + "</b> ";
}
if (res === "") return undefined;
return res;
}
return undefined;
};

View file

@ -109,6 +109,12 @@ const ruleScreenshotC2PA = (): FlagMatchRule[] => {
match: [C2PASourceTypeScreenCapture],
description: "Screen capture",
},
{
field:
"integrity/c2pa/manifest_info/manifests[]/assertions[label=c2pa.actions.v2]/data/actions[action=c2pa.created]/digitalSourceType",
match: [C2PASourceTypeScreenCapture],
description: "Screen capture",
},
];
};
@ -131,6 +137,12 @@ const ruleCamera = (): FlagMatchRule[] => {
match: [C2PASourceTypeDigitalCapture, C2PASourceTypeComputationalCapture, C2PASourceTypeCompositeCapture],
description: "Captured by camera",
},
{
field:
"integrity/c2pa/manifest_info/manifests[]/assertions[label=c2pa.actions.v2]/data/actions[action=c2pa.created]/digitalSourceType",
match: [C2PASourceTypeDigitalCapture, C2PASourceTypeComputationalCapture, C2PASourceTypeCompositeCapture],
description: "Captured by camera",
},
];
};
@ -142,6 +154,12 @@ const ruleAiGenerated = (): FlagMatchRule[] => {
match: [C2PASourceTypeTrainedAlgorithmicMedia, C2PASourceTypeCompositeWithTrainedAlgorithmicMedia],
description: "Generated by AI",
},
{
field:
"integrity/c2pa/manifest_info/manifests[]/assertions[label=c2pa.actions.v2]/data/actions[action=c2pa.created]/digitalSourceType",
match: [C2PASourceTypeTrainedAlgorithmicMedia, C2PASourceTypeCompositeWithTrainedAlgorithmicMedia],
description: "Generated by AI",
},
];
};
@ -319,10 +337,16 @@ export const extractProofHintFlags = (proof?: Proof): ProofHintFlags | undefined
let dateCreated: Date | undefined = undefined;
let dateCreatedSource: ProofHintFlagSource | undefined = undefined;
const creationAction = extractFlagValues(
let creationAction = extractFlagValues(
"integrity/c2pa/manifest_info/manifests[]/assertions[label=c2pa.actions]/data/actions[action=c2pa.created]",
rootMatchPath
);
if (creationAction.length == 0) {
creationAction = extractFlagValues(
"integrity/c2pa/manifest_info/manifests[]/assertions[label=c2pa.actions.v2]/data/actions[action=c2pa.created]",
rootMatchPath
);
}
if (creationAction.length > 0) {
source = softwareAgentFromAction(creationAction[0]);
dateCreated = getFirstWithDataAsDate(["when", "../../metadata/dateTime", "../../../signature_info/time"], creationAction[0].path);