Skip to content

Commit

Permalink
Lexicon: misc fixes to chat lexicons (#2499)
Browse files Browse the repository at this point in the history
* lexicon: misc chat-related tweaks/fixes

* ozone: track convo ids on chat message reports

* add changeset

* fix tests

---------

Co-authored-by: dholms <dtholmgren@gmail.com>
  • Loading branch information
devinivy and dholms authored May 20, 2024
1 parent e09b4c1 commit 06d2328
Show file tree
Hide file tree
Showing 29 changed files with 123 additions and 69 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-pears-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/api": patch
---

Misc tweaks and fixes to chat lexicons
6 changes: 3 additions & 3 deletions lexicons/chat/bsky/convo/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"defs": {
"messageRef": {
"type": "object",
"required": ["did", "messageId"],
"required": ["did", "messageId", "convoId"],
"properties": {
"did": { "type": "string", "format": "did" },
"convoId": { "type": "string" },
"messageId": { "type": "string" }
}
},
"message": {
"messageInput": {
"type": "object",
"required": ["text"],
"properties": {
"id": { "type": "string" },
"text": {
"type": "string",
"maxLength": 10000,
Expand Down
2 changes: 1 addition & 1 deletion lexicons/chat/bsky/convo/sendMessage.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"convoId": { "type": "string" },
"message": {
"type": "ref",
"ref": "chat.bsky.convo.defs#message"
"ref": "chat.bsky.convo.defs#messageInput"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion lexicons/chat/bsky/convo/sendMessageBatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"properties": {
"items": {
"type": "array",
"maxLength": 100,
"items": {
"type": "ref",
"ref": "#batchItem"
Expand Down Expand Up @@ -44,7 +45,7 @@
"convoId": { "type": "string" },
"message": {
"type": "ref",
"ref": "chat.bsky.convo.defs#message"
"ref": "chat.bsky.convo.defs#messageInput"
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions lexicons/chat/bsky/moderation/getMessageContext.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"type": "params",
"required": ["messageId"],
"properties": {
"convoId": {
"type": "string",
"description": "Conversation that the message is from. NOTE: this field will eventually be required."
},
"messageId": { "type": "string" },
"before": { "type": "integer", "default": 5 },
"after": { "type": "integer", "default": 5 }
Expand Down
20 changes: 13 additions & 7 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8306,24 +8306,24 @@ export const schemaDict = {
defs: {
messageRef: {
type: 'object',
required: ['did', 'messageId'],
required: ['did', 'messageId', 'convoId'],
properties: {
did: {
type: 'string',
format: 'did',
},
convoId: {
type: 'string',
},
messageId: {
type: 'string',
},
},
},
message: {
messageInput: {
type: 'object',
required: ['text'],
properties: {
id: {
type: 'string',
},
text: {
type: 'string',
maxLength: 10000,
Expand Down Expand Up @@ -8825,7 +8825,7 @@ export const schemaDict = {
},
message: {
type: 'ref',
ref: 'lex:chat.bsky.convo.defs#message',
ref: 'lex:chat.bsky.convo.defs#messageInput',
},
},
},
Expand Down Expand Up @@ -8854,6 +8854,7 @@ export const schemaDict = {
properties: {
items: {
type: 'array',
maxLength: 100,
items: {
type: 'ref',
ref: 'lex:chat.bsky.convo.sendMessageBatch#batchItem',
Expand Down Expand Up @@ -8888,7 +8889,7 @@ export const schemaDict = {
},
message: {
type: 'ref',
ref: 'lex:chat.bsky.convo.defs#message',
ref: 'lex:chat.bsky.convo.defs#messageInput',
},
},
},
Expand Down Expand Up @@ -9038,6 +9039,11 @@ export const schemaDict = {
type: 'params',
required: ['messageId'],
properties: {
convoId: {
type: 'string',
description:
'Conversation that the message is from. NOTE: this field will eventually be required.',
},
messageId: {
type: 'string',
},
Expand Down
12 changes: 6 additions & 6 deletions packages/api/src/client/types/chat/bsky/convo/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as ChatBskyActorDefs from '../actor/defs'

export interface MessageRef {
did: string
convoId: string
messageId: string
[k: string]: unknown
}
Expand All @@ -27,25 +28,24 @@ export function validateMessageRef(v: unknown): ValidationResult {
return lexicons.validate('chat.bsky.convo.defs#messageRef', v)
}

export interface Message {
id?: string
export interface MessageInput {
text: string
/** Annotations of text (mentions, URLs, hashtags, etc) */
facets?: AppBskyRichtextFacet.Main[]
embed?: AppBskyEmbedRecord.Main | { $type: string; [k: string]: unknown }
[k: string]: unknown
}

export function isMessage(v: unknown): v is Message {
export function isMessageInput(v: unknown): v is MessageInput {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'chat.bsky.convo.defs#message'
v.$type === 'chat.bsky.convo.defs#messageInput'
)
}

export function validateMessage(v: unknown): ValidationResult {
return lexicons.validate('chat.bsky.convo.defs#message', v)
export function validateMessageInput(v: unknown): ValidationResult {
return lexicons.validate('chat.bsky.convo.defs#messageInput', v)
}

export interface MessageView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface QueryParams {}

export interface InputSchema {
convoId: string
message: ChatBskyConvoDefs.Message
message: ChatBskyConvoDefs.MessageInput
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function toKnownErr(e: any) {

export interface BatchItem {
convoId: string
message: ChatBskyConvoDefs.Message
message: ChatBskyConvoDefs.MessageInput
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { CID } from 'multiformats/cid'
import * as ChatBskyConvoDefs from '../convo/defs'

export interface QueryParams {
/** Conversation that the message is from. NOTE: this field will eventually be required. */
convoId?: string
messageId: string
before?: number
after?: number
Expand Down
20 changes: 13 additions & 7 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8306,24 +8306,24 @@ export const schemaDict = {
defs: {
messageRef: {
type: 'object',
required: ['did', 'messageId'],
required: ['did', 'messageId', 'convoId'],
properties: {
did: {
type: 'string',
format: 'did',
},
convoId: {
type: 'string',
},
messageId: {
type: 'string',
},
},
},
message: {
messageInput: {
type: 'object',
required: ['text'],
properties: {
id: {
type: 'string',
},
text: {
type: 'string',
maxLength: 10000,
Expand Down Expand Up @@ -8825,7 +8825,7 @@ export const schemaDict = {
},
message: {
type: 'ref',
ref: 'lex:chat.bsky.convo.defs#message',
ref: 'lex:chat.bsky.convo.defs#messageInput',
},
},
},
Expand Down Expand Up @@ -8854,6 +8854,7 @@ export const schemaDict = {
properties: {
items: {
type: 'array',
maxLength: 100,
items: {
type: 'ref',
ref: 'lex:chat.bsky.convo.sendMessageBatch#batchItem',
Expand Down Expand Up @@ -8888,7 +8889,7 @@ export const schemaDict = {
},
message: {
type: 'ref',
ref: 'lex:chat.bsky.convo.defs#message',
ref: 'lex:chat.bsky.convo.defs#messageInput',
},
},
},
Expand Down Expand Up @@ -9038,6 +9039,11 @@ export const schemaDict = {
type: 'params',
required: ['messageId'],
properties: {
convoId: {
type: 'string',
description:
'Conversation that the message is from. NOTE: this field will eventually be required.',
},
messageId: {
type: 'string',
},
Expand Down
12 changes: 6 additions & 6 deletions packages/bsky/src/lexicon/types/chat/bsky/convo/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as ChatBskyActorDefs from '../actor/defs'

export interface MessageRef {
did: string
convoId: string
messageId: string
[k: string]: unknown
}
Expand All @@ -27,25 +28,24 @@ export function validateMessageRef(v: unknown): ValidationResult {
return lexicons.validate('chat.bsky.convo.defs#messageRef', v)
}

export interface Message {
id?: string
export interface MessageInput {
text: string
/** Annotations of text (mentions, URLs, hashtags, etc) */
facets?: AppBskyRichtextFacet.Main[]
embed?: AppBskyEmbedRecord.Main | { $type: string; [k: string]: unknown }
[k: string]: unknown
}

export function isMessage(v: unknown): v is Message {
export function isMessageInput(v: unknown): v is MessageInput {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'chat.bsky.convo.defs#message'
v.$type === 'chat.bsky.convo.defs#messageInput'
)
}

export function validateMessage(v: unknown): ValidationResult {
return lexicons.validate('chat.bsky.convo.defs#message', v)
export function validateMessageInput(v: unknown): ValidationResult {
return lexicons.validate('chat.bsky.convo.defs#messageInput', v)
}

export interface MessageView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface QueryParams {}

export interface InputSchema {
convoId: string
message: ChatBskyConvoDefs.Message
message: ChatBskyConvoDefs.MessageInput
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export type Handler<HA extends HandlerAuth = never> = (

export interface BatchItem {
convoId: string
message: ChatBskyConvoDefs.Message
message: ChatBskyConvoDefs.MessageInput
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
import * as ChatBskyConvoDefs from '../convo/defs'

export interface QueryParams {
/** Conversation that the message is from. NOTE: this field will eventually be required. */
convoId?: string
messageId: string
before: number
after: number
Expand Down
20 changes: 13 additions & 7 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8306,24 +8306,24 @@ export const schemaDict = {
defs: {
messageRef: {
type: 'object',
required: ['did', 'messageId'],
required: ['did', 'messageId', 'convoId'],
properties: {
did: {
type: 'string',
format: 'did',
},
convoId: {
type: 'string',
},
messageId: {
type: 'string',
},
},
},
message: {
messageInput: {
type: 'object',
required: ['text'],
properties: {
id: {
type: 'string',
},
text: {
type: 'string',
maxLength: 10000,
Expand Down Expand Up @@ -8825,7 +8825,7 @@ export const schemaDict = {
},
message: {
type: 'ref',
ref: 'lex:chat.bsky.convo.defs#message',
ref: 'lex:chat.bsky.convo.defs#messageInput',
},
},
},
Expand Down Expand Up @@ -8854,6 +8854,7 @@ export const schemaDict = {
properties: {
items: {
type: 'array',
maxLength: 100,
items: {
type: 'ref',
ref: 'lex:chat.bsky.convo.sendMessageBatch#batchItem',
Expand Down Expand Up @@ -8888,7 +8889,7 @@ export const schemaDict = {
},
message: {
type: 'ref',
ref: 'lex:chat.bsky.convo.defs#message',
ref: 'lex:chat.bsky.convo.defs#messageInput',
},
},
},
Expand Down Expand Up @@ -9038,6 +9039,11 @@ export const schemaDict = {
type: 'params',
required: ['messageId'],
properties: {
convoId: {
type: 'string',
description:
'Conversation that the message is from. NOTE: this field will eventually be required.',
},
messageId: {
type: 'string',
},
Expand Down
Loading

0 comments on commit 06d2328

Please sign in to comment.