Add bot badge to items created with API key (#1209)
This commit is contained in:
parent
050122c665
commit
d2a981ca5d
|
@ -1311,6 +1311,9 @@ export const createItem = async (parent, { forward, options, ...item }, { me, mo
|
||||||
item.url = removeTracking(item.url)
|
item.url = removeTracking(item.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mark item as created with API key
|
||||||
|
item.apiKey = me?.apiKey
|
||||||
|
|
||||||
const uploadIds = uploadIdsFromText(item.text, { models })
|
const uploadIds = uploadIdsFromText(item.text, { models })
|
||||||
const { totalFees: imgFees } = await imageFeesInfo(uploadIds, { models, me })
|
const { totalFees: imgFees } = await imageFeesInfo(uploadIds, { models, me })
|
||||||
|
|
||||||
|
@ -1433,7 +1436,7 @@ export const SELECT =
|
||||||
"Item".ncomments, "Item"."commentMsats", "Item"."lastCommentAt", "Item"."weightedVotes",
|
"Item".ncomments, "Item"."commentMsats", "Item"."lastCommentAt", "Item"."weightedVotes",
|
||||||
"Item"."weightedDownVotes", "Item".freebie, "Item".bio, "Item"."otsHash", "Item"."bountyPaidTo",
|
"Item"."weightedDownVotes", "Item".freebie, "Item".bio, "Item"."otsHash", "Item"."bountyPaidTo",
|
||||||
ltree2text("Item"."path") AS "path", "Item"."weightedComments", "Item"."imgproxyUrls", "Item".outlawed,
|
ltree2text("Item"."path") AS "path", "Item"."weightedComments", "Item"."imgproxyUrls", "Item".outlawed,
|
||||||
"Item"."pollExpiresAt"`
|
"Item"."pollExpiresAt", "Item"."apiKey"`
|
||||||
|
|
||||||
function topOrderByWeightedSats (me, models) {
|
function topOrderByWeightedSats (me, models) {
|
||||||
return `ORDER BY ${orderByNumerator(models)} DESC NULLS LAST, "Item".id DESC`
|
return `ORDER BY ${orderByNumerator(models)} DESC NULLS LAST, "Item".id DESC`
|
||||||
|
|
|
@ -125,6 +125,7 @@ export default gql`
|
||||||
forwards: [ItemForward]
|
forwards: [ItemForward]
|
||||||
imgproxyUrls: JSONObject
|
imgproxyUrls: JSONObject
|
||||||
rel: String
|
rel: String
|
||||||
|
apiKey: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
input ItemForwardInput {
|
input ItemForwardInput {
|
||||||
|
|
|
@ -136,6 +136,9 @@ export default function ItemInfo ({
|
||||||
{' '}<Badge className={styles.newComment} bg={null}>freebie</Badge>
|
{' '}<Badge className={styles.newComment} bg={null}>freebie</Badge>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
|
{(item.apiKey &&
|
||||||
|
<>{' '}<Badge className={styles.newComment} bg={null}>bot</Badge></>
|
||||||
|
)}
|
||||||
{extraBadges}
|
{extraBadges}
|
||||||
{canEdit && !item.deletedAt &&
|
{canEdit && !item.deletedAt &&
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -34,6 +34,7 @@ export const COMMENT_FIELDS = gql`
|
||||||
ncomments
|
ncomments
|
||||||
imgproxyUrls
|
imgproxyUrls
|
||||||
rel
|
rel
|
||||||
|
apiKey
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ export const ITEM_FIELDS = gql`
|
||||||
mine
|
mine
|
||||||
imgproxyUrls
|
imgproxyUrls
|
||||||
rel
|
rel
|
||||||
|
apiKey
|
||||||
}`
|
}`
|
||||||
|
|
||||||
export const ITEM_FULL_FIELDS = gql`
|
export const ITEM_FULL_FIELDS = gql`
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Item" ADD COLUMN "apiKey" BOOLEAN NOT NULL DEFAULT false;
|
|
@ -419,6 +419,7 @@ model Item {
|
||||||
ItemUpload ItemUpload[]
|
ItemUpload ItemUpload[]
|
||||||
uploadId Int?
|
uploadId Int?
|
||||||
outlawed Boolean @default(false)
|
outlawed Boolean @default(false)
|
||||||
|
apiKey Boolean @default(false)
|
||||||
pollExpiresAt DateTime?
|
pollExpiresAt DateTime?
|
||||||
Ancestors Reply[] @relation("AncestorReplyItem")
|
Ancestors Reply[] @relation("AncestorReplyItem")
|
||||||
Replies Reply[]
|
Replies Reply[]
|
||||||
|
|
Loading…
Reference in New Issue