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

Add create observation endpoint #42

Closed
wants to merge 6 commits into from
Closed

Add create observation endpoint #42

wants to merge 6 commits into from

Conversation

luandro
Copy link

@luandro luandro commented Jan 16, 2025

Adds a PUT /projects/:projectPublicId/observation route for creating new observations.

@gmaclennan
Copy link
Member

Can you explain the use-case for this? I'm wary because it removes some guarantees about observations that we have been discussing in the context of legal evidence and proof of observation provenance. And when discussed with Evan we wanted to minimize the API surface area of the server and the associated maintenance cost.

@luandro
Copy link
Author

luandro commented Jan 22, 2025

We're building a WhatsApp CoMapeo bot as part of an accelerator we're participating. There's already going to be a lot of security issues with it, so I think we just need to make sure to be explicit about the dangers of using CoMapeo DB outside the official applications.

There's no need to merge this into the main branch, it's ok to leave it as a separate branch. I can eventually fork the repo as part of a separate project.

@gmaclennan gmaclennan marked this pull request as draft January 23, 2025 21:02
@gmaclennan
Copy link
Member

Going to close this PR because it contains several changes that will break things for normal use, so I don't want to risk it being merged. Could you maybe move this work to a fork?

FYI the changes to auto-create keys will mean that you will not be able to sync this project with anyone nor add anyone to the project.

@gmaclennan gmaclennan closed this Jan 23, 2025
@luandro
Copy link
Author

luandro commented Jan 23, 2025 via email

@gmaclennan
Copy link
Member

The project ID is the public key of a key pair generated by the public creator. The server does not currently have a method to create a project, just join an existing one. By joining a project with a random project id, you are joining a project without a creator, and there is no role record giving the server permission to invite anyone. A device would not sync with the server in this state because there is no record of the server being added to the project. Once we add more role validation, the server in this state would probably not read the observations created on it, because there is no project membership record granting the server permission to create observations. Any membership record can only be created by a device with the correct permissions to create one, and that needs to be traced back to the project creator (who signs the membership records with the private key paired with the public key which is the project key).

@luandro
Copy link
Author

luandro commented Jan 23, 2025

So i first need to create a deviceId for the user right? Then it can sign the public key and make the whole thing work.

Looking at:

@gmaclennan
Copy link
Member

gmaclennan commented Jan 24, 2025 via email

@luandro
Copy link
Author

luandro commented Jan 24, 2025

Thanks for the explanation. I better understand now. I was making the wrong assumptions regarding how CoMapeo Cloud and the whole project creation flow works.

An ideal WhatsApp client would need to be able to create, update and delete observations to a CoMapeo database, which ideally would be able to sync back to the Android client through the Remote Archive.

But now I understand that's either not possible as invitation can only happen locally, or not desirable. The Cloud should only be able to create alerts.

I guess for now all we can do is create an alerts client, which can serve as a complementary tool for reporting from other people in a territory who aren't exactly part of the monitoring group. And also a non-secure mapping option using WhatsApp only, with the ability to migrate data to a CoMapeo project in the form of alerts in the future.

For what I was originally imagining, we'd need to have another class of data which is non-verifiable observations, that have audio, text and details attached to a location. Where trust would be put on the server to represent several devices associated with phone numbers. But for that the Android clients would have to be able to sync these as they do with alerts.

A minor feature that could be interesting, I imagine for the CMI use case as well, is having alerts be clickable links that take to external websites. That way other platforms can take care of presenting the richer data that are normally associated with alerts.

Here's a diagram of the WhatsApp bot that we'll be building, already updated to reflect the current limitations. It's part of this accelerator that we're participating:

stateDiagram-v2
    [*] --> Start
    
    state Start {
        WelcomeCard: Welcome! Are you reporting an incident or part of a safety group?
        WelcomeCard --> ReportingIncident: Report Incident
        WelcomeCard --> DefenseGroup: Safety Group Member
    }
    
    state ReportingIncident {
        VerifyCard: Verify your identity
        VerifyCard --> QRCodeVerification: Scan QR Code
        
        state QRCodeVerification {
            QRInstructions: Scan QR code to verify
            QRInstructions --> Verified: Verification Success
        }
        
        state Verified {
            LocationShare: Share incident location
            MediaUpload: Upload photos/audio
            LocationShare --> AlertGeneration
            MediaUpload --> AlertGeneration
            AlertGeneration: Generate Alert
            AlertGeneration --> ExistingCoMapeoGetAlerts
            ExistingCoMapeoGetAlerts --> ReceiveAlerts
        }
    }
    
    state DefenseGroup {
        PlatformChoice: Use secure CoMapeo application
        PlatformChoice --> CoMapeoPath: Yes
        PlatformChoice --> NonCoMapeoPath: No
    }
    
    state NonCoMapeoPath {
        CreateProject: Name your project
        CreateProject --> ProjectQRCode: Generate project QR code
        
        state ProjectQRCode {
            ShareLocation: Share project locations
            ShareMedia: Upload project media
            ProcessData: Process Observation
            ShareLocation --> ProcessData
            ShareMedia --> ProcessData
            NoMapeoGenerateReport: Generate report
            NoMapeoExportGeojson: Export data to GeoJson
            ProcessData --> NoMapeoGenerateReport
            ProcessData --> NoMapeoExportGeojson
            ProcessData --> MigrateToCoMapeo
            MigrateToCoMapeo: Migrate to CoMapeo via QR code
            MigrateToCoMapeo --> ExistingCoMapeo
        }
    }
    
    state CoMapeoPath {
        CoMapeoStatus: Already using CoMapeo?
        CoMapeoStatus --> ExistingCoMapeo: Yes
        CoMapeoStatus --> NewCoMapeo: No
        
        state ExistingCoMapeo {
            AdminVerify: Verify admin status
            AdminVerify --> QRInvite: Generate invite QR code
            
            state QRInvite {
                InviteTeam: Share QR code
                ReceiveAlerts: Get alerts
                ViewObservations: Check CoMapeo observations
                DownloadOfflineMaps: Download offline maps
                GenerateReport: Generate report
                ExportGeojson: Export data to GeoJson

            }
        }
        
        state NewCoMapeo {
            Onboarding: Tutorial/Categories
            Onboarding --> AdminVerify
        }
    }
Loading

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.

2 participants