nostros/frontend/Functions/RelayFunctions/DirectMessages/index.ts
2023-03-10 19:27:20 +01:00

23 lines
537 B
TypeScript

import { type DirectMessage } from '../../DatabaseFunctions/DirectMessages'
export const getOtherPubKey: (message: DirectMessage, ownPubKey: string) => string = (
message,
ownPubKey,
) => {
let otherPubKey = message.pubkey
if (otherPubKey === ownPubKey) {
otherPubKey = message.tags[0][1]
}
return otherPubKey
}
export const convertStringToByteArray: (string: string) => number[] = (string) => {
const bytes = []
for (let i = 0; i < string.length; ++i) {
bytes.push(string.charCodeAt(i))
}
return bytes
}