diff --git a/api/prisma/migrations/20241217135037_add_flag_categories/migration.sql b/api/prisma/migrations/20241217135037_add_flag_categories/migration.sql new file mode 100644 index 000000000..d220a7072 --- /dev/null +++ b/api/prisma/migrations/20241217135037_add_flag_categories/migration.sql @@ -0,0 +1,11 @@ +-- AlterEnum +-- This migration adds more than one value to an enum. +-- With PostgreSQL versions 11 and earlier, this is not possible +-- in a single migration. This can be worked around by creating +-- multiple migrations, each migration adding only one value to +-- the enum. + + +ALTER TYPE "PublicationFlagCategoryEnum" ADD VALUE 'UNDECLARED_AI'; +ALTER TYPE "PublicationFlagCategoryEnum" ADD VALUE 'NOT_IN_OCTOPUS_FORMAT'; +ALTER TYPE "PublicationFlagCategoryEnum" ADD VALUE 'IRRELEVANT_LINKED_PUBLICATION'; diff --git a/api/prisma/schema.prisma b/api/prisma/schema.prisma index 039108f98..0f3a62d39 100644 --- a/api/prisma/schema.prisma +++ b/api/prisma/schema.prisma @@ -354,6 +354,9 @@ enum PublicationFlagCategoryEnum { UNDECLARED_IMAGE_MANIPULATION COPYRIGHT INAPPROPRIATE + UNDECLARED_AI + NOT_IN_OCTOPUS_FORMAT + IRRELEVANT_LINKED_PUBLICATION } enum LicenceType { diff --git a/api/src/components/flag/controller.ts b/api/src/components/flag/controller.ts index bcabe14f8..2aee3000c 100644 --- a/api/src/components/flag/controller.ts +++ b/api/src/components/flag/controller.ts @@ -1,12 +1,13 @@ import * as cheerio from 'cheerio'; import nodemailer from 'nodemailer'; + +import * as email from 'lib/email'; +import * as flagService from 'flag/service'; import * as Helpers from 'lib/helpers'; -import * as response from 'lib/response'; +import * as I from 'interface'; import * as publicationService from 'publication/service'; -import * as flagService from 'flag/service'; +import * as response from 'lib/response'; import * as userService from 'user/service'; -import * as I from 'interface'; -import * as email from 'lib/email'; export const get = async (event: I.APIRequest): Promise => { try { @@ -48,14 +49,19 @@ export const getUserFlags = async ( } }; -const formatFlagType = (flagType: I.FlagCategory): string => { - const types = { +const formatFlagType = (flagType: I.PublicationFlagCategoryEnum): string => { + const types: { + [key in I.PublicationFlagCategoryEnum]: string; + } = { PLAGIARISM: 'Plagiarism', ETHICAL_ISSUES: 'Ethical issues', MISREPRESENTATION: 'Misrepresentation', UNDECLARED_IMAGE_MANIPULATION: 'Undeclared image manipulation', COPYRIGHT: 'Copyright', - INAPPROPRIATE: 'Inappropriate' + INAPPROPRIATE: 'Inappropriate', + UNDECLARED_AI: 'Undeclared use of generative AI', + NOT_IN_OCTOPUS_FORMAT: 'Not in Octopus format', + IRRELEVANT_LINKED_PUBLICATION: 'Linked to irrelevant publication' }; return types[flagType]; diff --git a/api/src/components/flag/schema/createFlag.ts b/api/src/components/flag/schema/createFlag.ts index ca1ebea31..bb3e09ccd 100644 --- a/api/src/components/flag/schema/createFlag.ts +++ b/api/src/components/flag/schema/createFlag.ts @@ -5,13 +5,16 @@ const updatedPublicationSchema: I.Schema = { properties: { category: { type: 'string', - enum: [ + enum: [ 'PLAGIARISM', 'ETHICAL_ISSUES', 'MISREPRESENTATION', 'UNDECLARED_IMAGE_MANIPULATION', 'COPYRIGHT', - 'INAPPROPRIATE' + 'INAPPROPRIATE', + 'UNDECLARED_AI', + 'NOT_IN_OCTOPUS_FORMAT', + 'IRRELEVANT_LINKED_PUBLICATION' ] }, comment: { diff --git a/api/src/lib/interface.ts b/api/src/lib/interface.ts index 6ed5c94c5..ea3ea277d 100644 --- a/api/src/lib/interface.ts +++ b/api/src/lib/interface.ts @@ -349,14 +349,6 @@ export interface ConfirmVerificationCodeBody { const prismaGeneratedFlagType = Prisma.validator()({}); export type Flag = Prisma.PublicationFlagsGetPayload; -export type FlagCategory = - | 'PLAGIARISM' - | 'ETHICAL_ISSUES' - | 'MISREPRESENTATION' - | 'UNDECLARED_IMAGE_MANIPULATION' - | 'COPYRIGHT' - | 'INAPPROPRIATE'; - export interface CreateFlagPathParams { publicationId: string; } diff --git a/ui/src/config/values.ts b/ui/src/config/values.ts index 72882be3f..44f2c3ce5 100644 --- a/ui/src/config/values.ts +++ b/ui/src/config/values.ts @@ -856,6 +856,18 @@ export const octopusInformation: Interfaces.OctopusInformation = { INAPPROPRIATE: { value: 'INAPPROPRIATE', nicename: 'Inappropriate' + }, + UNDECLARED_AI: { + value: 'UNDECLARED_AI', + nicename: 'Undeclared use of generative AI' + }, + NOT_IN_OCTOPUS_FORMAT: { + value: 'NOT_IN_OCTOPUS_FORMAT', + nicename: 'Not in Octopus format' + }, + IRRELEVANT_LINKED_PUBLICATION: { + value: 'IRRELEVANT_LINKED_PUBLICATION', + nicename: 'Linked to irrelevant publication' } } }; diff --git a/ui/src/lib/types.ts b/ui/src/lib/types.ts index 3641ac656..d9023edb4 100644 --- a/ui/src/lib/types.ts +++ b/ui/src/lib/types.ts @@ -112,7 +112,10 @@ export type RedFlagTypes = | 'MISREPRESENTATION' | 'UNDECLARED_IMAGE_MANIPULATION' | 'COPYRIGHT' - | 'INAPPROPRIATE'; + | 'INAPPROPRIATE' + | 'UNDECLARED_AI' + | 'NOT_IN_OCTOPUS_FORMAT' + | 'IRRELEVANT_LINKED_PUBLICATION'; export type Languages = | 'ab'