-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix sync test and expect results of sync call
- Loading branch information
Showing
4 changed files
with
52 additions
and
19 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,10 +1,27 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nomoSendMessage = void 0; | ||
const tslib_1 = require("tslib"); | ||
const axios_1 = tslib_1.__importDefault(require("axios")); | ||
const server = 'https://zeniq.chat/'; | ||
/** | ||
* TODO: document here | ||
*/ | ||
async function nomoSendMessage(args) { | ||
console.log("nomoSendMessage not implemented"); | ||
async function nomoSendMessage(args, accessToken) { | ||
let { roomId, content, transationID, eventType } = args; | ||
const url = server + `_matrix/client/v3/rooms/${roomId}/send/${eventType}/${transationID}`; | ||
try { | ||
const response = await axios_1.default.put(url, content, { | ||
headers: { | ||
'Authorization': `Bearer ${accessToken}`, | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
return response.data['event_id']; | ||
} | ||
catch (error) { | ||
console.error('Error sending message:', error); | ||
return ""; | ||
} | ||
} | ||
exports.nomoSendMessage = nomoSendMessage; |
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
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
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 |
---|---|---|
@@ -1,9 +1,27 @@ | ||
import { nomoRegisterOrLogin, nomoSyncUser, UserMatrix, nomoCreateFilter } from "../../src"; | ||
import { nomoRegisterOrLogin, nomoSyncUser, UserMatrix } from "../../src"; | ||
|
||
test("sync user", async () => { | ||
const mnemonic = "diet say develop title sibling steel blast table chicken foster fuel giraffe"; | ||
const userMatrix: UserMatrix = await nomoRegisterOrLogin(mnemonic); | ||
// const filterID: string = await nomoCreateFilter(userMatrix.access_token, userMatrix.user_id); | ||
// await nomoSyncUser(userMatrix.access_token, "", '', "online", false); | ||
// expect(userMatrix.user_id).toBe("@0x3f0e8cF0c6eb9789348541D9D0Ce4ac847277e9B:zeniq.chat"); | ||
}, 10000); | ||
const mnemonic = | ||
"diet say develop title sibling steel blast table chicken foster fuel giraffe"; | ||
const userMatrix: UserMatrix = await nomoRegisterOrLogin(mnemonic); | ||
|
||
expect(userMatrix.user_id).toBe( | ||
"@0xa563B68Ba292601968A4fb63861e9d847126E83E:zeniq.chat" | ||
); | ||
expect(userMatrix.home_server).toBe("zeniq.chat"); | ||
|
||
// const filterID: string = await nomoCreateFilter(userMatrix.access_token, userMatrix.user_id); | ||
const res = await nomoSyncUser( | ||
userMatrix.access_token, | ||
"", | ||
"", | ||
"online", | ||
false | ||
); | ||
expect(res.status).toBe(200); | ||
|
||
const data = res.data; | ||
console.log("sync data", data); | ||
|
||
expect(data.rooms).toBeDefined(); | ||
}, 10000); |