Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(video): add rules module to sendNotification() method & push video #881

Merged
merged 6 commits into from
Dec 18, 2023

Conversation

madhur-push
Copy link
Contributor

@madhur-push madhur-push commented Nov 24, 2023

  • Add changes in sendNotification, Video SDK
  • Incorporate changes in backend-sdk, frontend-sdk example apps
  • Add test case for video

@madhur-push madhur-push self-assigned this Nov 24, 2023
@madhur-push madhur-push linked an issue Nov 24, 2023 that may be closed by this pull request
Copy link

All looks good.

Copy link

File: packages/restapi/src/lib/payloads/constants.ts

  • Typo: request to be established should be request to establish - Line 8
  • Typo: speaker requests' gets promoted should be speaker requests - Line 12
  • Typo: CO_HOST should be COHOST - Line 32
  • Typo: speaker leaves a space should be speaker leaves the space - Line 34
  • Typo: LISTENER should be LISTENING - Line 36

File: packages/restapi/src/lib/payloads/helpers.ts

  • Typo: getCAIPDetails is missing e - Line 6
  • Typo: identityType: IDENTITY_TYPE; should be identityType: IDENTITY_TYPE; - Line 45
  • Typo: validationProof should be verificationProof - Line 52
  • Typo: acta should be act - Line 58
  • Typo: amsg should be msg - Line 60
  • Typo: asub should be sub - Line 62
  • Typo: etime should be expire - Line 64
  • Typo: getCAIPAddress is missing s - Line 84
  • Typo: const type = { is missing closing } - Line 111

File: packages/restapi/src/lib/payloads/sendNotifications.ts

  • Typo: Environment should be ENV - Line 102
  • Typo: env = Environment.PROD, should be env = ENV.PROD, - Line 124
  • Typo: const _recipients = await getRecipients({ should be const _recipients = await getRecipientFieldForAPIPayload({ - Line 136
  • Typo: const source = should be let source = - Line 145
  • Typo: recipient should be recipients - Line 172
  • Typo: } is missing closing ) - Line 174

File: packages/restapi/src/lib/payloads/types/index.ts

  • Typo: types/index.ts should be types.ts - Line 3

File: packages/restapi/src/lib/video/helpers/sendVideoCallNotification.ts

  • Typo: error( ...) should be console.error( ...) - Line 36

All looks good.

@madhur-push madhur-push marked this pull request as ready for review November 29, 2023 09:41
Copy link

File: packages/examples/sdk-backend-node/chat/chat.lowlevel.ts

  1. Typo: 'generatePrivateKey' should be 'generatedPrivateKey' on line 27.
  2. Typo: 'pgpDecrpyptedPvtKey' should be 'pgpDecryptedPvtKey' on line 59 and line 68.
  3. Typo: 'await PushAPI.chat.decryptPGPKey' should be 'await PushAPI.chat.decryptPGPPrivateKey' on line 68.
  4. Typo: 'crypto' should be 'crypt' on line 85.
  5. Typo: 'adjectives' on line 7, 'animals' on line 8, 'colors' on line 9, and 'uniqueNamesGenerator' on line 10 should be imported from 'unique-name-generator' instead of 'unique-names-generator'.
  6. Typo: 'VideoChatNotificationAccessType' on line 11 should be 'VIDEO_NOTIFICATION_ACCESS_TYPE'.
  7. Missing closing parenthesis on line 36 after 'Socket Disconnected'.
  8. Typo: 'pgpDecrpyptedPvtKey' should be 'pgpDecryptedPvtKey' on line 43.
  9. Typo: 'PushAPI_chat_send' should be 'PushAPI_chatSendMessage' on line 56.
  10. Missing closing parenthesis on line 63 after 'Incoming Push Chat message from Socket'.
  11. Typo: 'pgpDecrpyptedPvtKey' should be 'pgpDecryptedPvtKey' on line 73.
  12. Typo: 'video_call_notification' should be 'PushAPI_chat_video_call_notification' on line 82.
  13. Typo: 'async function' should be 'async function()' on line 82.
  14. Missing semicolon on line 82 at the end of the line.
  15. Missing closing curly brace on line 89.

File: packages/examples/sdk-frontend/pages/video.tsx

  1. Typo: 'ADDITIONAL_META_TYPE' on line 77, line 94, and line 111 should be 'VIDEO_CALL_TYPE'.
  2. Typo: 'user?.encryptedPrivateKey' on line 68 and line 115 should be 'user?.encryptedPGPPrivateKey'.
  3. Typo: 'data.user?.encryptedPrivateKey' on line 147 should be 'user?.encryptedPGPPrivateKey'.
  4. Typo: 'videoCallMetaData.signalingData' on line 206 should be 'videoCallMetaData.signalData'.

File: packages/restapi/src/lib/payloads/constants.ts

  1. Typo: 'EXPORT VideoCallStatus' should be 'export enum VideoCallStatus' on line 60.

All other code files look good.

Copy link

File: packages/examples/sdk-backend-node/chat/chat.lowlevel.ts

  1. The import statement for VIDEO_NOTIFICATION_ACCESS_TYPE from @pushprotocol/restapi/src/lib/payloads/constants is incorrect. It should be imported from @pushprotocol/restapi.

  2. There is a missing closing brace } after the pushSDKSocket.on(EVENTS.DISCONNECT, () => {}) line.

  3. There is an extra closing brace } before the const delay = (ms: number) => line.

  4. The await delay(4000) line should be inside the PushAPI_chat_send_message function.

  5. The recipients key in the PushAPI.payloads.sendNotification function should be inside the notification object.

  6. There is a missing closing brace } after the channel: signerAddress, // your channel address line.

  7. There are some commented lines of code that should be removed.

File: packages/examples/sdk-frontend/pages/video.tsx

  1. The import statement for ENV from @pushprotocol/restapi/src/lib/constants is incorrect. It should be imported from @pushprotocol/restapi.

  2. The VideoCallMetaDataType interface should be imported from @pushprotocol/restapi/src/lib/payloads/constants instead of being defined locally.

  3. There is a missing } after the acceptVideoCallRequest function.

  4. There is an extra opening brace { before the setIncomingVideoCall function.

  5. The connectHandler function is missing a closing brace }.

  6. There is an extra opening brace { before the useEffect hook.

  7. There is a missing closing brace } after the await videoObjectRef.current?.acceptRequest( line.

  8. There is a missing closing brace } after the useEffect hook.

  9. The PushAPI.chat.chats function should be awaited and assigned to the response variable.

  10. There is a missing closing brace } after the if (response?.length) { line.

  11. There are some commented lines of code that should be removed.

File: packages/restapi/src/lib/payloads/constants.ts

  1. The VIDEO_NOTIFICATION_ACCESS_TYPE enum is not exported.

Overall, the code seems to be missing some closing braces and there are a few incorrect import statements. Please make the necessary changes based on the above points.

Copy link

In the file chat.lowlevel.ts:

  1. There is a commented section of code for generating random wallet signers using ethers library. This section can be removed as it is not being used.

  2. The line const secondSignerAddress = secondSigner.account.address; is missing the assignment value, and it should be removed as well.

  3. There is an unclosed curly brace at the end of the pushSDKSocket.on(EVENTS.DISCONNECT, () => { block. It should be closed before the pushSDKSocket.on(EVENTS.CHAT_RECEIVED_MESSAGE, (message) => { block.

  4. The line const delay = (ms: number) => is missing its closing brace. It should be closed before the await delay(4000); line.

  5. In the PushAPI_chat_video_call_notification function, there is a missing closing brace before the let pgpDecrpyptedPvtKey = null; line.

  6. The line const apiResponse = await PushAPI.payloads.sendNotification({ is missing its closing brace. It should be closed before the console.log('PushAPI.payloads.sendNotification | Response - 204 OK'); line.

In the file video.tsx:

  1. The line import { ADDITIONAL_META_TYPE, VIDEO_NOTIFICATION_ACCESS_TYPE } from '@pushprotocol/restapi/src/lib/payloads/constants'; is importing constants that are already defined in the constants.ts file in the same directory. It can be removed.

  2. The line const { data: signer } = useSigner(); is destructuring the data property from the useSigner() hook, but the data property is not being used later in the code. It can be removed.

  3. The line let pgpPrivateKey = null; is declared within the if (user?.encryptedPrivateKey) { block but is used outside of it. It should be moved outside of the block.

  4. In the setIncomingVideoCall function, the line return produce(oldData, (draft) => { is missing its closing brace. It should be closed before the line draft.meta.initiator.signal = videoCallMetaData.signalData;.

  5. In the acceptVideoCallRequest function, the line rules: { is missing its closing brace. It should be closed before the } line.

  6. In the connectHandler function, the line peerAddress: senderAddress, is missing its closing brace. It should be closed before the } line.

  7. In the useEffect hook, the line let pgpPrivateKey = null; is declared within the if (user?.encryptedPrivateKey) { block but is used outside of it. It should be moved outside of the block.

  8. The line const { payload } = latestFeedItem || {}; is destructuring the payload property from the latestFeedItem variable but the latestFeedItem variable is not being used later in the code. It can be removed.

  9. In the line if (!Object.prototype.hasOwnProperty.call(payload, 'data') ||, the payload object should be checked for null before accessing its properties to avoid potential errors.

  10. Missing closing braces after the following lines:

  • if (!additionalMeta) return;
  • if (additionalMeta.type !== ${ADDITIONAL_META_TYPE.PUSH_VIDEO}+1) return;
  • if (videoCallMetaData.status === PushAPI.VideoCallStatus.INITIALIZED) {
  • if (data.local.stream && currentStatus === PushAPI.VideoCallStatus.INITIALIZED) {
  • if (!data.local.stream) return;
  • if (!pushSocket?.connected) {

Overall, there are some syntax errors, missing closing braces, and unused code in the provided files. After addressing these issues, the code should be reviewed again for logic and functionality.

@madhur-push
Copy link
Contributor Author

@mohammeds1992 We need to hold the merge for this PR, this needs BE changes to be reviewed and merged first. BE PR: https://github.com/ethereum-push-notification-service/push-storage-node/pull/1368

cc: @Aman035

Copy link

In the file packages/examples/sdk-backend-node/chat/chat.lowlevel.ts:

  • There is a commented out block of code that uses ethers library for creating random wallet signers. It seems unnecessary and can be removed.
  • The variable secondSigner is declared but not assigned any value. It should be assigned a value similar to signer variable.
  • There is a missing closing brace } for the pushSDKSocket.on(EVENTS.DISCONNECT, () => { statement.
  • There is a missing closing brace } for the pushSDKSocket.on(EVENTS.CHAT_RECEIVED_MESSAGE, (message) => { statement.
  • There is a typo in the variable name pgpDecrpyptedPvtKey. It should be pgpDecryptedPvtKey.
  • The delay function is not used anywhere and can be removed.

In the file packages/examples/sdk-frontend/pages/video.tsx:

  • There is a missing closing brace } for the produce(oldData, (draft) => { statement.
  • There is a missing closing brace } for the acceptVideoCallRequest function.
  • There is a missing closing brace } for the connectHandler function.
  • There is a missing closing brace ) for the setData( statement.
  • There is a missing closing parenthesis ) for the apiResponse logging statement.
  • There is a missing closing brace } for the useEffect(() => { statement.
  • There is a missing closing parenthesis ) for the setIncomingVideoCall(videoCallMetaData); statement.
  • There is a missing closing parenthesis ) for the setRequestVideoCall function.
  • There is a missing closing parenthesis ) for the videoObjectRef.current?.acceptRequest({ statement.

In the file packages/restapi/src/lib/payloads/constants.ts:

  • There is a missing closing brace } for the SPACE_DISCONNECT_TYPE enum.
  • There is a missing closing brace } for the SPACE_INVITE_ROLES enum.
  • There is a missing closing brace } for the SPACE_ROLES enum.

@madhur-push madhur-push merged commit df0917b into main Dec 18, 2023
1 check passed
@madhur-push madhur-push deleted the feat-add-rules-module-to-push-video branch December 18, 2023 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

😈 Push Video - Add rules module to sendNotification() method
3 participants