bounswe / 2021SpringGroup4

This is the project repository of Group 4 for Boğaziçi University's Fundamentals of Software Engineering course.
2 stars 1 forks source link

Backend: Implement comment functionality for events #199

Closed kerimoglutolga closed 2 years ago

kerimoglutolga commented 2 years ago

Description

Being able to leave comments on an event and discuss it afterward serves an important purpose as users can judge previous events of a particular creator and share their own opinion. The comment functionality should ideally be incorporated directly into the event structure at the backend without creating a separate app. The endpoints should be simple and convenient and comments of an event should also be visible with using the currently available event endpoints.

kerimoglutolga commented 2 years ago

Done! Find the related pr here: https://github.com/bounswe/2021SpringGroup4/pull/172/

I have integrated the comment structure under the events model. To create an event, you can send a POST request to the endpoint /api/events/comment/ with the body of the comment and the id of the event you wish to comment on.

An example request

{
    "body": "This event is amazing!",
    "parent": "1"
}

Now, you can retrieve this event and access it's comments field.

 {
        "@context": "https://www.w3.org/ns/activitystreams",
        "id": 1,
        "creator": "tolga",
        "created": "2021-11-30T12:10:22.134589+03:00",
        "type": "Event",
        "body": {
            "title": "TestEvent1",
            "description": "This is a test event.",
            "date": "2021-10-21",
            "time": "21:00:00",
            "duration": "02:00:00",
            "location": "Istanbul",
            "sportType": "",
            "maxPlayers": 10,
            "applicants": [],
            "participants": [],
            "comments": [
                {
                    "id": 6,
                    "owner": "tolga",
                    "parent": 1,
                    "body": "This event is amazing!"
                }
            ],
            "skill_level": "Beginner",
            "lat": null,
            "long": null
        }
    }