Skip to content

Commit

Permalink
Revert "Feat/messages"
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAndrei98 authored Aug 29, 2023
1 parent 2b82aba commit 4c9bfe1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 77 deletions.
57 changes: 0 additions & 57 deletions src/keri/app/signify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,6 @@ export class SignifyClient {
escrows(): Escrows {
return new Escrows(this)
}

/**
* Get messages resource
* @returns {Messages}
* */
messages(): Messages {
return new Messages(this)
}
}

/** Arguments required to create an identfier */
Expand Down Expand Up @@ -1809,52 +1801,3 @@ export class Escrows {
return await res.json()
}
}


/**
* Messages
*/

export class Messages {
client: SignifyClient

/**
* Messages
* @param {SignifyClient} client
*/
constructor(client: SignifyClient) {
this.client = client
}

/**
* List messages
* @async
* @param {string} [sender] sender prefix to filter messages
* @param {string} [recipient] recipient prefix to filter messages
* @param {number} [start=0] Start index of list of messages, defaults to 0
* @param {number} [end=9] End index of list of messages, defaults to 9
*/
async list(sender:string, recipient:string, start:number=0, end:number=9): Promise<any> {
let extraHeaders = new Headers()
extraHeaders.append('Range', `messages=${start}-${end}`)
let params = new URLSearchParams()
//check sender and recipient are send otherwise return error
if (sender !== undefined) {params.append('sender', sender)}
if (recipient !== undefined) {params.append('recipient', recipient)}


let path = `/messages`+ '?' + params.toString()
let method = 'GET'
let res = await this.client.fetch(path, method, null, extraHeaders)
let cr = res.headers.get('content-range')
let range = parseRangeHeaders(cr,"messages")
let msgs = await res.json()

return {
start: range.start,
end: range.end,
total: range.total,
messages: msgs
}
}
}
21 changes: 1 addition & 20 deletions test/app/signify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,24 +723,5 @@ describe('SignifyClient', () => {
assert.equal(lastCall[1]!.method,'GET')

})

it('Messages', async () => {
await libsodium.ready;
const bran = "0123456789abcdefghijk"

let client = new SignifyClient(url,bran,Tier.low,boot_url)

await client.boot()
await client.connect()

let messages = client.messages()

await messages.list('ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose','EMQQpnSkgfUOgWdzQTWfrgiVHKIDAhvAZIPQ6z3EAfz1',0, 10)
let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
assert.equal(lastCall[0]!,url+'/messages?sender=ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose&recipient=EMQQpnSkgfUOgWdzQTWfrgiVHKIDAhvAZIPQ6z3EAfz1')
assert.equal(lastCall[1]!.method,'GET')

let lastHeaders = new Headers((lastCall[1]!.headers!))
assert.equal(lastHeaders.get('Range'),'messages=0-10')
})

})

0 comments on commit 4c9bfe1

Please sign in to comment.