import { MAX_NUMBER_PARENTS } from "../binary/message" ; import { SingleNodeClient } from "../clients/singleNodeClient" ; import type { IClient } from "../models/IClient" ; import type { IMessage } from "../models/IMessage" ; param client param messageId returns export async function promote ( client , messageId ) { const localClient = typeof client === "string" ? new SingleNodeClient ( client ) : client ; const message = await localClient . message ( messageId ) ; if ( ! message ) { throw new Error ( "The message does not exist." ) ; } const tipsResponse = await localClient . tips ( ) ; if ( ! tipsResponse . tipMessageIds . includes ( messageId ) ) { tipsResponse . tipMessageIds . unshift ( messageId ) ; } if ( tipsResponse . tipMessageIds . length > MAX_NUMBER_PARENTS ) { tipsResponse . tipMessageIds = tipsResponse . tipMessageIds . slice ( 0 , MAX_NUMBER_PARENTS ) ; } tipsResponse . tipMessageIds . sort ( ) ; const promoteMessage = { parentMessageIds : tipsResponse . tipMessageIds } ; const promoteMessageId = await localClient . messageSubmit ( promoteMessage ) ; return { message , messageId : promoteMessageId } ; }