aticie / Mapper-Influences-Backend

0 stars 0 forks source link

Activity websocket #31

Closed 112batuhan closed 3 months ago

112batuhan commented 3 months ago

closes #28 Basic websocket implementation to track and broadcast basic user actions to showcase on home page. Can't add INFLUENCE_BEATMAP_ADD or similar event because with current implementation, it's not easy to determine if we are adding map or adding a brand new influence (mongo upsert :fearful: ) I can do it in a way that's not efficient but I will come up with something.

also #31 SĞKSBKİSJİVAJİVAJŞFAJŞFAŞHFSŞJAFŞJ

Since we won't have it in documentation. I'm adding it here.

On first connection, server sends the last 10 activities to the client. After that, each client will get latest activity one by one as they happen.

There are 3 events. I will add one example for each:

{
    "type": "ADD_INFLUENCE",
    "user": {
        "id": 3953470,
        "username": "112servis",
        "avatar_url": "https://a.ppy.sh/3953470?1619015829.jpeg",
        "country": "TR"
    },
    "datetime": "2024-06-06T00:58:23.585112",
    "details": {
        "influenced_to": 1848318,
        "beatmap": null,
        "description": "hehehe"
    }
}
{
    "type": "ADD_BEATMAP",
    "user": {
        "id": 3953470,
        "username": "112servis",
        "avatar_url": "https://a.ppy.sh/3953470?1619015829.jpeg",
        "country": "TR"
    },
    "datetime": "2024-06-06T00:58:04.853939",
    "details": {
        "influenced_to": null,
        "beatmap": {
            "is_beatmapset": false,
            "id": 2777733
        },
        "description": null
    }
}
{
    "type": "EDIT_BIO",
    "user": {
        "id": 3953470,
        "username": "112servis",
        "avatar_url": "https://a.ppy.sh/3953470?1619015829.jpeg",
        "country": "TR"
    },
    "datetime": "2024-06-06T00:57:58.272656",
    "details": {
        "influenced_to": null,
        "beatmap": null,
        "description": "test test\n"
    }
}
112batuhan commented 3 months ago

I will add tests tmr because I'm sleepy

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud