mirror of
https://github.com/Discreetly/server.git
synced 2026-04-17 03:00:55 -04:00
feat(endpoints) adding js docs to endpoint functions
This commit is contained in:
@@ -52,9 +52,10 @@ time stamp to prevent replay attacks
|
||||
|
||||
https://github.com/Discreetly/IdentityCommitmentNullifierCircuit <- Circuit and JS to do this
|
||||
*/
|
||||
|
||||
/**
|
||||
* This function takes in an identity and returns the rooms the identity is in.
|
||||
* @param identity - the identity of a user
|
||||
* @param {string[]} identity - the identity of a user
|
||||
* @returns an array of roomIds
|
||||
*/
|
||||
export async function findRoomsByIdentity(identity: string): Promise<string[]> {
|
||||
@@ -93,6 +94,11 @@ export async function findClaimCode(code: string): Promise<ClaimCodeI | null> {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a gateway identity in the database.
|
||||
* @param {string} identity - The identity to find
|
||||
* @returns
|
||||
*/
|
||||
export async function findGatewayByIdentity(
|
||||
identity: string
|
||||
): Promise<GateWayIdentityI | null> {
|
||||
@@ -122,6 +128,12 @@ export async function findUpdatedRooms(roomIds: string[]): Promise<RoomI[]> {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to find a room in the database using a message and the roomId and returns the room
|
||||
* @param {string} roomId - The id of the room to find
|
||||
* @param {MessageI} message - The id of message to find
|
||||
* @returns
|
||||
*/
|
||||
export async function findRoomWithMessageId(
|
||||
roomId: string,
|
||||
message: MessageI
|
||||
@@ -156,6 +168,12 @@ export async function findRoomWithMessageId(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to find groups in the database that the ethereum address is in
|
||||
* @param {string} group - The type of the group to find
|
||||
* @param {string} group - The address of the group to find
|
||||
* @returns
|
||||
*/
|
||||
export function findManyGroups(
|
||||
group: string,
|
||||
address?: string
|
||||
@@ -204,6 +222,11 @@ export function findManyGroups(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to find a group in the database and returns the groups ethereum addresses
|
||||
* @param {string} name - The name of the group to find
|
||||
* @returns {Promise<{ ethereumAddresses: string[] } | null>} - A promise that resolves to the group
|
||||
*/
|
||||
export function findUniqueEthGroup(
|
||||
name: string
|
||||
): Promise<{ ethereumAddresses: string[] } | null> {
|
||||
@@ -217,6 +240,11 @@ export function findUniqueEthGroup(
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to find messages in a room
|
||||
* @param {string} roomId - The id of the room to find messages in
|
||||
* @returns {void}
|
||||
*/
|
||||
export function findMessages(roomId : string) {
|
||||
return prisma.messages
|
||||
.findMany({
|
||||
|
||||
@@ -321,6 +321,13 @@ export async function createEthGroupForRoom(
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string[]} names - The names of the ethereum groups to add the addresses to
|
||||
* @param {string[]} ethAddresses - An array of ethereum addresses to add to the groups
|
||||
* @returns
|
||||
*/
|
||||
export function addAddressesToEthGroup(names: string[], ethAddresses: string[]) {
|
||||
return prisma.ethereumGroup.updateMany({
|
||||
where: {
|
||||
@@ -336,7 +343,13 @@ export function addAddressesToEthGroup(names: string[], ethAddresses: string[])
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function updates an ethereum group in the database.
|
||||
* @param {string} name - The name of the ethereum group to update
|
||||
* @param {string[]} ethAddresses - An array of ethereum addresses to add to the group
|
||||
* @param {string[]} roomIds - The ids of the rooms to connect to the group
|
||||
* @returns
|
||||
*/
|
||||
export function updateEthGroup(name: string, ethAddresses: string[], roomIds: string[]) {
|
||||
return prisma.ethereumGroup.update({
|
||||
where: {
|
||||
@@ -352,5 +365,3 @@ export function updateEthGroup(name: string, ethAddresses: string[], roomIds: st
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user