()
| 103 | }; |
| 104 | |
| 105 | const sendMessage = async () => { |
| 106 | // get all the users of this chatroom |
| 107 | const authUser = await Auth.currentAuthenticatedUser(); |
| 108 | |
| 109 | const users = (await DataStore.query(ChatRoomUser)) |
| 110 | .filter((cru) => cru.chatroom.id === chatRoom.id) |
| 111 | .map((cru) => cru.user); |
| 112 | |
| 113 | console.log("users", users); |
| 114 | |
| 115 | // for each user, encrypt the `content` with his public key, and save it as a new message |
| 116 | await Promise.all( |
| 117 | users.map((user) => sendMessageToUser(user, authUser.attributes.sub)) |
| 118 | ); |
| 119 | |
| 120 | resetFields(); |
| 121 | }; |
| 122 | |
| 123 | const updateLastMessage = async (newMessage) => { |
| 124 | DataStore.save( |
no test coverage detected