DreamExposure / DisCal-Discord-Bot

DisCal is a Discord Bot that links up to a Google Calendar to create, delete, edit, and announce events and more!
GNU General Public License v3.0
112 stars 44 forks source link

API Timestamps inconsistent #123

Closed phraustbyte closed 2 years ago

phraustbyte commented 2 years ago

Who is the bug affecting?

Administrators

What is affected by this bug?

API

When does this occur?

When updating an event

I am editing an event to adjust the start and end times (by one hour) This is the request body:

{
    "guild_id": "<GuildIdRemoved>",
    "calendar_number": 1,
    "event_id": "euhq9soh41",
    "epoch_start": "1638972000",
    "epoch_end": "1638973740"
}

Note that the timestamps should update the start end dates as follows: Start: Wednesday, December 8, 2021 2:00:00 PM End: Wednesday, December 8, 2021 2:29:00 PM

When the post request completes. the following information is returned from the API:

{
    "event": {
        "calendar": {
            "external": false,
            "calendar_id": "balbjbra4dbj86kl4vqaev8vp4@group.calendar.google.com",
            "timezone": "America/Toronto",
            "guild_id": "<GuildIdRemoved>",
            "calendar_number": 1,
            "host": "GOOGLE",
            "name": "MH Events",
            "link": "https://www.discalbot.com/embed/<GuildIdRemoved>/calendar/1",
            "description": "Territory Events",
            "host_link": "https://calendar.google.com/calendar/embed?src=balbjbra4dbj86kl4vqaev8vp4@group.calendar.google.com",
            "calendar_address": "balbjbra4dbj86kl4vqaev8vp4@group.calendar.google.com"
        },
        "image": "",
        "color": "BLUE",
        "epoch_start": 1638972000,
        "epoch_end": 1638973000,
        "description": "Territory Defense",
        "is_parent": true,
        "recurrence": {
            "count": -1,
            "interval": 1,
            "frequency": "WEEKLY"
        },
        "rrule": "RRULE:FREQ=WEEKLY;INTERVAL=1",
        "event_id": "euhq9soh41",
        "guild_id": "Snowflake{<GuildIdRemoved>}",
        "name": "[NOVA] Perim (1*)",
        "recur": true,
        "location": ""
    },
    "message": "Success"
}

Note the inconsistency between the epoch times listed in the request and listed in the body. It is off by 15 minutes.

When running /events view euhq9soh41 I get this: image

It looks like the API might be updating the database with a null value. As a side note, the API documentation indicate that the epoch start/end times are to be long values, but in the code, these are string that are converted to long value body.getString("epoch_start").toLong(). Posting this as a long results in an error.

NovaFox161 commented 2 years ago

Ah, this would be because we accept unix timestamps in milliseconds not seconds.

V3 will be accepting them in ISO 8601 when that eventually happens.