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

Announcements do not support multi-cal #137

Closed NovaFox161 closed 2 years ago

NovaFox161 commented 2 years ago

Who is the bug affecting?

Any users with multiple calendars

What is affected by this bug?

Announcements sent to a calendar other than the first, revert to the first

When does this occur?

Whenever an announcement is created/edited

Where on the platform does it happen?

Bot

How do we replicate the issue?

Read above

jbies121 commented 2 years ago

I think the symptom may be because the calendarNumber is being cached?

DisCal-Discord-Bot\client\src\main\kotlin\org\dreamexposure\discal\client\service\AnnouncementService.kt

private fun getCalendar(guild: Guild, announcement: Announcement): Mono<Calendar> {
        val cached = getCached(announcement.guildId)

        return if (!cached.calendars.contains(announcement.calendarNumber)) {
            guild.getCalendar(announcement.calendarNumber)
                .doOnNext { cached.calendars[it.calendarNumber] = it }
        } else Mono.justOrEmpty(cached.calendars[announcement.calendarNumber])
    }
NovaFox161 commented 2 years ago

Looks more like some fields are not being set correctly when fetching from the database. Not sure what happened here. (Affects all announcement fetch methods) https://github.com/DreamExposure/DisCal-Discord-Bot/blob/77d6f9cec1ac34694edc4b6136aa7a471a5ce904/core/src/main/kotlin/org/dreamexposure/discal/core/database/DatabaseManager.kt#L774-L776

NovaFox161 commented 2 years ago

Resolved in 73a5229ed1705a8a58af05fb69dd613dd104ba71

Will go live in 4.2.2

This seemed to have only affected when an announcement is fetched by ID, so it has a limited scope of impact.