Flockingbird / hunter2

Hunter2 is a job hunt bot that indexes jobs and candidates from the fediverse
https://search.flockingbird.social
MIT License
14 stars 1 forks source link

Ensure we have a unique UUID v5 based on the AP_ID url for each account #4

Closed berkes closed 2 years ago

berkes commented 2 years ago

Use deterministic, yet random ID as primary key when storing accounts.

We used to have

use uuid::Uuid
//....

        // TODO: Investigate why this is broken. Maybe "as_bytes()" returns the same bytes?
        // Because it currently always returns 1b4db7eb-4057-5ddf-91e0-36dec72071f5 as UUID.
        let uuid = Uuid::new_v5(&Uuid::NAMESPACE_URL, &account.ap_id.as_bytes());
        account.ap_id = account.id;
        account.id = uuid.to_hyphenated().to_string();

But this, somehow, resulted in the same UUID being used everywhere. It is now reverted to use ap_id, which is a string containing an URL. But at least those are unique!