-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add join as speaker * refactor: add file level comment * refactor: eOF * refactor: rm speaker check logic * fix: getPlain added * fix: rm updation
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/restapi/src/lib/spaceV2/helpers/sendMetaMessage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @file sendMetaMessage helper function | ||
* This module provides a function for sending metadata-related messages within a live space. | ||
*/ | ||
|
||
import { send } from '../../chat'; | ||
import { MessageType } from '../../constants'; | ||
import { EnvOptionsType, LiveSpaceData, SignerType } from '../../types'; | ||
import { META_ACTION } from '../../types/messageTypes'; | ||
|
||
interface ISendMetaMessage extends EnvOptionsType { | ||
liveSpaceData?: LiveSpaceData; | ||
action: META_ACTION; | ||
spaceId: string; | ||
pgpPrivateKey: string; | ||
signer: SignerType; | ||
} | ||
|
||
const sendMetaMessage = async ({ | ||
liveSpaceData, | ||
action, | ||
spaceId, | ||
pgpPrivateKey, | ||
signer, | ||
env, | ||
}: ISendMetaMessage) => { | ||
await send({ | ||
receiverAddress: spaceId, | ||
pgpPrivateKey, | ||
env, | ||
signer, | ||
messageType: MessageType.META, | ||
messageObj: { | ||
content: 'PUSH SPACE V2 META MESSAGE', | ||
action, | ||
info: { | ||
affected: [], | ||
arbitrary: liveSpaceData, | ||
}, | ||
}, | ||
}); | ||
}; | ||
|
||
export default sendMetaMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @file joinAsSpeaker | ||
* defines a function that allows a user to join a space as a speaker in the SpaceV2 implmentation | ||
*/ | ||
|
||
import { SpaceV2 } from './SpaceV2'; | ||
import sendMetaMessage from './helpers/sendMetaMessage' | ||
|
||
import { META_ACTION } from '../types'; | ||
|
||
export async function joinAsSpeaker(this: SpaceV2) { | ||
try { | ||
// send meta message to host | ||
await sendMetaMessage({ | ||
pgpPrivateKey: this.pgpPrivateKey, | ||
env: this.env, | ||
spaceId: this.data.spaceInfo.spaceId, | ||
signer: this.signer, | ||
// TODO: add relevant meta message later | ||
action: META_ACTION.ADD_MEMBER, | ||
}); | ||
|
||
/* rest logic to be implemented here after host has called the approve/reject call */ | ||
} catch (err) { | ||
console.error(`[Push SDK] - API - Error - API ${joinAsSpeaker.name} -: `, err); | ||
throw Error(`[Push SDK] - API - Error - API ${joinAsSpeaker.name} -: ${err}`); | ||
} | ||
}; |