Skip to content

Commit

Permalink
✨ Search accounts by email domain works
Browse files Browse the repository at this point in the history
  • Loading branch information
foysalit committed Apr 18, 2024
1 parent 6f1f544 commit 01f15c3
Show file tree
Hide file tree
Showing 18 changed files with 537 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lexicons/com/atproto/admin/searchAccounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"lexicon": 1,
"id": "com.atproto.admin.searchAccounts",
"defs": {
"main": {
"type": "query",
"description": "Get list of accounts that matches your search query.",
"parameters": {
"type": "params",
"properties": {
"email": { "type": "string" }
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["cursor", "accounts"],
"properties": {
"cursor": { "type": "string" },
"accounts": {
"type": "array",
"items": {
"type": "ref",
"ref": "com.atproto.admin.defs#accountView"
}
}
}
}
}
}
}
}
13 changes: 13 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as ComAtprotoAdminGetAccountInfo from './types/com/atproto/admin/getAcc
import * as ComAtprotoAdminGetAccountInfos from './types/com/atproto/admin/getAccountInfos'
import * as ComAtprotoAdminGetInviteCodes from './types/com/atproto/admin/getInviteCodes'
import * as ComAtprotoAdminGetSubjectStatus from './types/com/atproto/admin/getSubjectStatus'
import * as ComAtprotoAdminSearchAccounts from './types/com/atproto/admin/searchAccounts'
import * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail'
import * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail'
import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle'
Expand Down Expand Up @@ -177,6 +178,7 @@ export * as ComAtprotoAdminGetAccountInfo from './types/com/atproto/admin/getAcc
export * as ComAtprotoAdminGetAccountInfos from './types/com/atproto/admin/getAccountInfos'
export * as ComAtprotoAdminGetInviteCodes from './types/com/atproto/admin/getInviteCodes'
export * as ComAtprotoAdminGetSubjectStatus from './types/com/atproto/admin/getSubjectStatus'
export * as ComAtprotoAdminSearchAccounts from './types/com/atproto/admin/searchAccounts'
export * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail'
export * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail'
export * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle'
Expand Down Expand Up @@ -524,6 +526,17 @@ export class ComAtprotoAdminNS {
})
}

searchAccounts(
params?: ComAtprotoAdminSearchAccounts.QueryParams,
opts?: ComAtprotoAdminSearchAccounts.CallOptions,
): Promise<ComAtprotoAdminSearchAccounts.Response> {
return this._service.xrpc
.call('com.atproto.admin.searchAccounts', params, undefined, opts)
.catch((e) => {
throw ComAtprotoAdminSearchAccounts.toKnownErr(e)
})
}

sendEmail(
data?: ComAtprotoAdminSendEmail.InputSchema,
opts?: ComAtprotoAdminSendEmail.CallOptions,
Expand Down
38 changes: 38 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,43 @@ export const schemaDict = {
},
},
},
ComAtprotoAdminSearchAccounts: {
lexicon: 1,
id: 'com.atproto.admin.searchAccounts',
defs: {
main: {
type: 'query',
description: 'Get list of accounts that matches your search query.',
parameters: {
type: 'params',
properties: {
email: {
type: 'string',
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['cursor', 'accounts'],
properties: {
cursor: {
type: 'string',
},
accounts: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.admin.defs#accountView',
},
},
},
},
},
},
},
},
ComAtprotoAdminSendEmail: {
lexicon: 1,
id: 'com.atproto.admin.sendEmail',
Expand Down Expand Up @@ -9540,6 +9577,7 @@ export const ids = {
ComAtprotoAdminGetAccountInfos: 'com.atproto.admin.getAccountInfos',
ComAtprotoAdminGetInviteCodes: 'com.atproto.admin.getInviteCodes',
ComAtprotoAdminGetSubjectStatus: 'com.atproto.admin.getSubjectStatus',
ComAtprotoAdminSearchAccounts: 'com.atproto.admin.searchAccounts',
ComAtprotoAdminSendEmail: 'com.atproto.admin.sendEmail',
ComAtprotoAdminUpdateAccountEmail: 'com.atproto.admin.updateAccountEmail',
ComAtprotoAdminUpdateAccountHandle: 'com.atproto.admin.updateAccountHandle',
Expand Down
37 changes: 37 additions & 0 deletions packages/api/src/client/types/com/atproto/admin/searchAccounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import { Headers, XRPCError } from '@atproto/xrpc'
import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { isObj, hasProp } from '../../../../util'
import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'
import * as ComAtprotoAdminDefs from './defs'

export interface QueryParams {
email?: string
}

export type InputSchema = undefined

export interface OutputSchema {
cursor: string
accounts: ComAtprotoAdminDefs.AccountView[]
[k: string]: unknown
}

export interface CallOptions {
headers?: Headers
}

export interface Response {
success: boolean
headers: Headers
data: OutputSchema
}

export function toKnownErr(e: any) {
if (e instanceof XRPCError) {
}
return e
}
12 changes: 12 additions & 0 deletions packages/bsky/src/lexicon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as ComAtprotoAdminGetAccountInfo from './types/com/atproto/admin/getAcc
import * as ComAtprotoAdminGetAccountInfos from './types/com/atproto/admin/getAccountInfos'
import * as ComAtprotoAdminGetInviteCodes from './types/com/atproto/admin/getInviteCodes'
import * as ComAtprotoAdminGetSubjectStatus from './types/com/atproto/admin/getSubjectStatus'
import * as ComAtprotoAdminSearchAccounts from './types/com/atproto/admin/searchAccounts'
import * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail'
import * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail'
import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle'
Expand Down Expand Up @@ -303,6 +304,17 @@ export class ComAtprotoAdminNS {
return this._server.xrpc.method(nsid, cfg)
}

searchAccounts<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
ComAtprotoAdminSearchAccounts.Handler<ExtractAuth<AV>>,
ComAtprotoAdminSearchAccounts.HandlerReqCtx<ExtractAuth<AV>>
>,
) {
const nsid = 'com.atproto.admin.searchAccounts' // @ts-ignore
return this._server.xrpc.method(nsid, cfg)
}

sendEmail<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
Expand Down
38 changes: 38 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,43 @@ export const schemaDict = {
},
},
},
ComAtprotoAdminSearchAccounts: {
lexicon: 1,
id: 'com.atproto.admin.searchAccounts',
defs: {
main: {
type: 'query',
description: 'Get list of accounts that matches your search query.',
parameters: {
type: 'params',
properties: {
email: {
type: 'string',
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['cursor', 'accounts'],
properties: {
cursor: {
type: 'string',
},
accounts: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.admin.defs#accountView',
},
},
},
},
},
},
},
},
ComAtprotoAdminSendEmail: {
lexicon: 1,
id: 'com.atproto.admin.sendEmail',
Expand Down Expand Up @@ -8163,6 +8200,7 @@ export const ids = {
ComAtprotoAdminGetAccountInfos: 'com.atproto.admin.getAccountInfos',
ComAtprotoAdminGetInviteCodes: 'com.atproto.admin.getInviteCodes',
ComAtprotoAdminGetSubjectStatus: 'com.atproto.admin.getSubjectStatus',
ComAtprotoAdminSearchAccounts: 'com.atproto.admin.searchAccounts',
ComAtprotoAdminSendEmail: 'com.atproto.admin.sendEmail',
ComAtprotoAdminUpdateAccountEmail: 'com.atproto.admin.updateAccountEmail',
ComAtprotoAdminUpdateAccountHandle: 'com.atproto.admin.updateAccountHandle',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import express from 'express'
import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { lexicons } from '../../../../lexicons'
import { isObj, hasProp } from '../../../../util'
import { CID } from 'multiformats/cid'
import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
import * as ComAtprotoAdminDefs from './defs'

export interface QueryParams {
email?: string
}

export type InputSchema = undefined

export interface OutputSchema {
cursor: string
accounts: ComAtprotoAdminDefs.AccountView[]
[k: string]: unknown
}

export type HandlerInput = undefined

export interface HandlerSuccess {
encoding: 'application/json'
body: OutputSchema
headers?: { [key: string]: string }
}

export interface HandlerError {
status: number
message?: string
}

export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
export type HandlerReqCtx<HA extends HandlerAuth = never> = {
auth: HA
params: QueryParams
input: HandlerInput
req: express.Request
res: express.Response
}
export type Handler<HA extends HandlerAuth = never> = (
ctx: HandlerReqCtx<HA>,
) => Promise<HandlerOutput> | HandlerOutput
12 changes: 12 additions & 0 deletions packages/ozone/src/lexicon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as ComAtprotoAdminGetAccountInfo from './types/com/atproto/admin/getAcc
import * as ComAtprotoAdminGetAccountInfos from './types/com/atproto/admin/getAccountInfos'
import * as ComAtprotoAdminGetInviteCodes from './types/com/atproto/admin/getInviteCodes'
import * as ComAtprotoAdminGetSubjectStatus from './types/com/atproto/admin/getSubjectStatus'
import * as ComAtprotoAdminSearchAccounts from './types/com/atproto/admin/searchAccounts'
import * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail'
import * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail'
import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle'
Expand Down Expand Up @@ -322,6 +323,17 @@ export class ComAtprotoAdminNS {
return this._server.xrpc.method(nsid, cfg)
}

searchAccounts<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
ComAtprotoAdminSearchAccounts.Handler<ExtractAuth<AV>>,
ComAtprotoAdminSearchAccounts.HandlerReqCtx<ExtractAuth<AV>>
>,
) {
const nsid = 'com.atproto.admin.searchAccounts' // @ts-ignore
return this._server.xrpc.method(nsid, cfg)
}

sendEmail<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
Expand Down
38 changes: 38 additions & 0 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,43 @@ export const schemaDict = {
},
},
},
ComAtprotoAdminSearchAccounts: {
lexicon: 1,
id: 'com.atproto.admin.searchAccounts',
defs: {
main: {
type: 'query',
description: 'Get list of accounts that matches your search query.',
parameters: {
type: 'params',
properties: {
email: {
type: 'string',
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['cursor', 'accounts'],
properties: {
cursor: {
type: 'string',
},
accounts: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.admin.defs#accountView',
},
},
},
},
},
},
},
},
ComAtprotoAdminSendEmail: {
lexicon: 1,
id: 'com.atproto.admin.sendEmail',
Expand Down Expand Up @@ -9540,6 +9577,7 @@ export const ids = {
ComAtprotoAdminGetAccountInfos: 'com.atproto.admin.getAccountInfos',
ComAtprotoAdminGetInviteCodes: 'com.atproto.admin.getInviteCodes',
ComAtprotoAdminGetSubjectStatus: 'com.atproto.admin.getSubjectStatus',
ComAtprotoAdminSearchAccounts: 'com.atproto.admin.searchAccounts',
ComAtprotoAdminSendEmail: 'com.atproto.admin.sendEmail',
ComAtprotoAdminUpdateAccountEmail: 'com.atproto.admin.updateAccountEmail',
ComAtprotoAdminUpdateAccountHandle: 'com.atproto.admin.updateAccountHandle',
Expand Down

0 comments on commit 01f15c3

Please sign in to comment.