Repository: louislam/uptime-kuma
File: server/notification-providers/google-chat.js (JavaScript)

Code before:
                });
            }

            // add button for monitor link if available
            const baseURL = await setting("primaryBaseURL");
            if (baseURL) {
                sectionWidgets.push({
                    buttonList: {
                        buttons: [
                            {
                                text: "Visit Uptime Kuma",
                                onClick: {
                                    openLink: {
                                        url:
                                            baseURL + (monitorJSON ? getMonitorRelativeURL(
                                                monitorJSON.id
                                            ) : "/"),
                                    },
                                },
                            },
                        ],
                    },
                });
            }

            // construct first section
            let chatSections = [
                {
                    widgets: sectionWidgets,
                },
            ];

            // construct json data
            let data = {
                cardsV2: [
                    {
                        card: {
                            header: chatHeader,
                            sections: chatSections,
                        },
                    },
                ],
            };

            await axios.post(notification.googleChatWebhookURL, data);
            return okMsg;
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }

    }

Review comment (suggestion):
nit:not the first section but only one. Would ining this be more or less readable?

```suggestion
```

Code after:
                });
            }

            // add button for monitor link if available
            const baseURL = await setting("primaryBaseURL");
            if (baseURL) {
                const urlPath = monitorJSON ? getMonitorRelativeURL(monitorJSON.id) : "/";
                sectionWidgets.push({
                    buttonList: {
                        buttons: [
                            {
                                text: "Visit Uptime Kuma",
                                onClick: {
                                    openLink: {
                                        url: baseURL + urlPath,
                                    },
                                },
                            },
                        ],
                    },
                });
            }

            let chatSections = [
                {
                    widgets: sectionWidgets,
                },
            ];

            // construct json data
            let data = {
                cardsV2: [
                    {
                        card: {
                            header: chatHeader,
                            sections: chatSections,
                        },
                    },
                ],
            };

            await axios.post(notification.googleChatWebhookURL, data);
            return okMsg;
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }

    }
}

module.exports = GoogleChat;