Add bot badge to items created with API key (#1209)

This commit is contained in:
ekzyis 2024-05-30 16:23:07 -05:00 committed by GitHub
parent 050122c665
commit d2a981ca5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 13 additions and 1 deletions

View File

@ -1311,6 +1311,9 @@ export const createItem = async (parent, { forward, options, ...item }, { me, mo
item.url = removeTracking(item.url)
}
// mark item as created with API key
item.apiKey = me?.apiKey
const uploadIds = uploadIdsFromText(item.text, { models })
const { totalFees: imgFees } = await imageFeesInfo(uploadIds, { models, me })
@ -1433,7 +1436,7 @@ export const SELECT =
"Item".ncomments, "Item"."commentMsats", "Item"."lastCommentAt", "Item"."weightedVotes",
"Item"."weightedDownVotes", "Item".freebie, "Item".bio, "Item"."otsHash", "Item"."bountyPaidTo",
ltree2text("Item"."path") AS "path", "Item"."weightedComments", "Item"."imgproxyUrls", "Item".outlawed,
"Item"."pollExpiresAt"`
"Item"."pollExpiresAt", "Item"."apiKey"`
function topOrderByWeightedSats (me, models) {
return `ORDER BY ${orderByNumerator(models)} DESC NULLS LAST, "Item".id DESC`

View File

@ -125,6 +125,7 @@ export default gql`
forwards: [ItemForward]
imgproxyUrls: JSONObject
rel: String
apiKey: Boolean
}
input ItemForwardInput {

View File

@ -136,6 +136,9 @@ export default function ItemInfo ({
{' '}<Badge className={styles.newComment} bg={null}>freebie</Badge>
</Link>
)}
{(item.apiKey &&
<>{' '}<Badge className={styles.newComment} bg={null}>bot</Badge></>
)}
{extraBadges}
{canEdit && !item.deletedAt &&
<>

View File

@ -34,6 +34,7 @@ export const COMMENT_FIELDS = gql`
ncomments
imgproxyUrls
rel
apiKey
}
`

View File

@ -59,6 +59,7 @@ export const ITEM_FIELDS = gql`
mine
imgproxyUrls
rel
apiKey
}`
export const ITEM_FULL_FIELDS = gql`

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Item" ADD COLUMN "apiKey" BOOLEAN NOT NULL DEFAULT false;

View File

@ -419,6 +419,7 @@ model Item {
ItemUpload ItemUpload[]
uploadId Int?
outlawed Boolean @default(false)
apiKey Boolean @default(false)
pollExpiresAt DateTime?
Ancestors Reply[] @relation("AncestorReplyItem")
Replies Reply[]