opentrace-community / opentrace-cloud-functions

OpenTrace Cloud Functions. Reference implementation of the BlueTrace protocol.
https://bluetrace.io
GNU General Public License v3.0
273 stars 121 forks source link

Simulate Positive case, trigger upload code #12

Open valduze opened 4 years ago

valduze commented 4 years ago

Hi guys, I got everything working, now I would like to know, how to I simulate a active case, for example, I have installed this on two Android phones close by, so I want the other phone to act a a user who is positive and upload data.

Trigger the upload code.

Any Documentation for that. Thanks, Jongi

amauryVedana commented 4 years ago

On positive case phone, you go to upload, press next, press next on step 1, then enter your pin code, this will fire upload of records from the phone and uploadDataProcess will be execute on firebase.

jcavieres commented 4 years ago

I made it work, but as far as I understood from the source code there are 2 issues here:

  1. Tokens have to be previously created in the collection "codes" of the database . Nothing about this is explained in the Readme file.

  2. The processUploadedData function is not implemented in the code. const processUploadedData = async (object: ObjectMetadata) => { throw new functions.https.HttpsError('unimplemented', 'Not implemented yet'); }; What does this function do?

amauryVedana commented 4 years ago

1 => yes there is opened issue about this https://github.com/opentrace-community/opentrace-cloud-functions/issues/9 2 => yes you need to implement that one with the wanted behaviour, but it's already fired after an history upload.

egottardo commented 4 years ago

On positive case phone, you go to upload, press next, press next on step 1, then enter your pin code, this will fire upload of records from the phone and uploadDataProcess will be execute on firebase.

How can I get/generate the pin?

qtangs commented 4 years ago

Please see https://github.com/opentrace-community/opentrace-cloud-functions/issues/9#issuecomment-614786773 for the upload code generation.

Logic for processUploadedData is not included yet. For now you can use this to read the file content and parse it:

const fileContentBuffer = admin.storage().bucket(object.bucket).download(); const {token, records, events} = JSON.parse(fileContentBuffer.toString()); // validate upload token const {uid, uploadCode} = await validateToken(token, validateTokenTimestamp); // validateToken from getUploadToken.ts // decrypt TempIDs in records // ... // store/share validated records // ...

redlight55 commented 4 years ago

Please see #9 (comment) for the upload code generation.

Logic for processUploadedData is not included yet. For now you can use this to read the file content and parse it:

const fileContentBuffer = admin.storage().bucket(object.bucket).download(); const {token, records, events} = JSON.parse(fileContentBuffer.toString()); // validate upload token const {uid, uploadCode} = await validateToken(token, validateTokenTimestamp); // validateToken from getUploadToken.ts // decrypt TempIDs in records // ... // store/share validated records // ...

Hi @qtangs On const fileContentBuffer = admin.storage().bucket(object.bucket).download();, it gives out an error Property 'download' does not exist on type 'Bucket'. Is this implemented inside the processUploadedData function? Need help on this.

rburhum commented 4 years ago

Please see #9 (comment) for the upload code generation. Logic for processUploadedData is not included yet. For now you can use this to read the file content and parse it:

const fileContentBuffer = admin.storage().bucket(object.bucket).download(); const {token, records, events} = JSON.parse(fileContentBuffer.toString()); // validate upload token const {uid, uploadCode} = await validateToken(token, validateTokenTimestamp); // validateToken from getUploadToken.ts // decrypt TempIDs in records // ... // store/share validated records // ...

Hi @qtangs On const fileContentBuffer = admin.storage().bucket(object.bucket).download();, it gives out an error Property 'download' does not exist on type 'Bucket'. Is this implemented inside the processUploadedData function? Need help on this.

+1

qtangs commented 4 years ago

We have shared a reference implementation for processUploadedData, you can find the logic here:

https://github.com/opentrace-community/opentrace-cloud-functions/blob/master/functions/src/opentrace/processUploadedData.ts#L24