diff --git a/backend/internal/meeting/migrations.go b/backend/internal/meeting/migrations.go
index 2ad96b5..68c3231 100644
--- a/backend/internal/meeting/migrations.go
+++ b/backend/internal/meeting/migrations.go
@@ -37,7 +37,11 @@ func Migrations() []migration.Migration {
{
Version: 4,
SQL: `CREATE INDEX IF NOT EXISTS idx_meeting_votes_meeting
- ON meeting_votes(meeting_id);`,
+ ON meeting_votes(meeting_id);`,
+ },
+ {
+ Version: 5,
+ SQL: `ALTER TABLE meetings ADD COLUMN has_notification INTEGER NOT NULL DEFAULT 1;`,
},
}
}
diff --git a/backend/internal/meeting/model.go b/backend/internal/meeting/model.go
index 861484f..30d008e 100644
--- a/backend/internal/meeting/model.go
+++ b/backend/internal/meeting/model.go
@@ -19,6 +19,11 @@ type Meeting struct {
CreatedBy int64
CreatedAt time.Time
+ // HasNotification reports whether the meeting should be announced by
+ // notification consumers such as the Telegram bot. When false the meeting
+ // is created silently.
+ HasNotification bool
+
// Fields below are filled by the repository and are relative to the user
// requesting the meeting: the author's display name, the display names of
// the users who voted to join or not join, the resulting tallies and the
diff --git a/backend/internal/meeting/repository.go b/backend/internal/meeting/repository.go
index b04a0bb..7dee05b 100644
--- a/backend/internal/meeting/repository.go
+++ b/backend/internal/meeting/repository.go
@@ -24,7 +24,7 @@ type Repository struct {
// the requesting user's own vote. The first placeholder is the viewer's user id,
// used for the my_vote column. Voter names and tallies are attached separately
// by attachVoters.
-const meetingColumns = `m.id, m.title, m.intent, m.room, m.scheduled_at, m.created_by, m.created_at,
+const meetingColumns = `m.id, m.title, m.intent, m.room, m.scheduled_at, m.created_by, m.created_at, m.has_notification,
COALESCE(NULLIF(u.fullname, ''), u.login, '') AS created_by_name,
COALESCE((SELECT v.vote FROM meeting_votes v WHERE v.meeting_id = m.id AND v.user_id = ?), '') AS my_vote`
@@ -44,7 +44,7 @@ func scanMeeting(row rowScanner) (*Meeting, error) {
m := &Meeting{}
var scheduledAt, createdAt time.Time
err := row.Scan(
- &m.Id, &m.Title, &m.Intent, &m.Room, &scheduledAt, &m.CreatedBy, &createdAt,
+ &m.Id, &m.Title, &m.Intent, &m.Room, &scheduledAt, &m.CreatedBy, &createdAt, &m.HasNotification,
&m.CreatedByName, &m.MyVote,
)
if err != nil {
@@ -116,8 +116,8 @@ ORDER BY u.login ASC`
}
func (r *Repository) CreateMeeting(ctx context.Context, m *Meeting) (*Meeting, error) {
- query := "INSERT INTO meetings(title, intent, room, scheduled_at, created_by, created_at) VALUES(?, ?, ?, ?, ?, ?) RETURNING id"
- err := r.q.QueryRowContext(ctx, query, m.Title, m.Intent, m.Room, m.ScheduledAt, m.CreatedBy, m.CreatedAt).Scan(&m.Id)
+ query := "INSERT INTO meetings(title, intent, room, scheduled_at, created_by, created_at, has_notification) VALUES(?, ?, ?, ?, ?, ?, ?) RETURNING id"
+ err := r.q.QueryRowContext(ctx, query, m.Title, m.Intent, m.Room, m.ScheduledAt, m.CreatedBy, m.CreatedAt, m.HasNotification).Scan(&m.Id)
if err != nil {
slog.Error("create meeting", slog.String("op", "repo.CreateMeeting"), slog.Int64("user_id", m.CreatedBy), slog.Any("error", err))
return nil, ErrInternal
diff --git a/backend/internal/meeting/service.go b/backend/internal/meeting/service.go
index f488ac8..dcc6e71 100644
--- a/backend/internal/meeting/service.go
+++ b/backend/internal/meeting/service.go
@@ -23,8 +23,10 @@ func NewService(r *Repository) (*Service, error) {
// Create validates and stores a new meeting authored by u. When autoJoin is
// true the author's "join" vote is cast immediately so the meeting reflects
-// their intent to attend.
-func (s *Service) Create(ctx context.Context, u *user.User, title, intent, room string, scheduledAt time.Time, autoJoin bool) (*Meeting, error) {
+// their intent to attend. When hasNotification is true the meeting is eligible
+// for announcement by notification consumers such as the Telegram bot; when
+// false it is created silently.
+func (s *Service) Create(ctx context.Context, u *user.User, title, intent, room string, scheduledAt time.Time, autoJoin, hasNotification bool) (*Meeting, error) {
if u == nil {
slog.Error("nil user", slog.String("op", "service.Create"))
return nil, ErrInternal
@@ -38,12 +40,13 @@ func (s *Service) Create(ctx context.Context, u *user.User, title, intent, room
}
created, err := s.r.CreateMeeting(ctx, &Meeting{
- Title: title,
- Intent: intent,
- Room: room,
- ScheduledAt: scheduledAt.UTC(),
- CreatedBy: u.Id,
- CreatedAt: time.Now().UTC(),
+ Title: title,
+ Intent: intent,
+ Room: room,
+ ScheduledAt: scheduledAt.UTC(),
+ CreatedBy: u.Id,
+ CreatedAt: time.Now().UTC(),
+ HasNotification: hasNotification,
})
if err != nil {
return nil, err
diff --git a/backend/internal/rest/handler_meetings.go b/backend/internal/rest/handler_meetings.go
index a01b787..0a2c073 100644
--- a/backend/internal/rest/handler_meetings.go
+++ b/backend/internal/rest/handler_meetings.go
@@ -16,6 +16,10 @@ type createMeetingRequest struct {
// AutoJoin asks the server to record the author's own "join" vote so the
// meeting carries their intent to attend from the moment it is created.
AutoJoin bool `json:"autoJoin"`
+ // HasNotification controls whether notification consumers (such as the
+ // Telegram bot) announce the meeting. It is a pointer so an omitted field
+ // can be distinguished from an explicit false and defaults to enabled.
+ HasNotification *bool `json:"hasNotification"`
}
type voteMeetingRequest struct {
@@ -36,6 +40,9 @@ type meetingResponse struct {
JoinCount int `json:"joinCount"`
DeclineCount int `json:"declineCount"`
MyVote string `json:"myVote"`
+ // HasNotification mirrors the stored flag so clients can show whether the
+ // meeting will be announced.
+ HasNotification bool `json:"hasNotification"`
}
func (h *Handler) listMeetings(w http.ResponseWriter, r *http.Request) {
@@ -71,7 +78,14 @@ func (h *Handler) createMeeting(w http.ResponseWriter, r *http.Request) {
return
}
- created, err := h.meetings.Create(r.Context(), u, req.Title, req.Intent, req.Room, scheduledAt, req.AutoJoin)
+ // Omitted hasNotification defaults to true so existing clients keep
+ // announcing meetings unless they explicitly opt out.
+ hasNotification := true
+ if req.HasNotification != nil {
+ hasNotification = *req.HasNotification
+ }
+
+ created, err := h.meetings.Create(r.Context(), u, req.Title, req.Intent, req.Room, scheduledAt, req.AutoJoin, hasNotification)
if err != nil {
h.fail(w, err)
return
@@ -154,5 +168,7 @@ func newMeetingResponse(m *meeting.Meeting) meetingResponse {
JoinCount: m.JoinCount,
DeclineCount: m.DeclineCount,
MyVote: m.MyVote,
+
+ HasNotification: m.HasNotification,
}
}
diff --git a/bots/_smoke_test.py b/bots/_smoke_test.py
index 5e642ff..3efb9eb 100644
--- a/bots/_smoke_test.py
+++ b/bots/_smoke_test.py
@@ -20,7 +20,7 @@ from meetings_telegram_bot.state import StateStore
now = datetime.now(timezone.utc)
-def mk(i, title="T", room=None, sched=None):
+def mk(i, title="T", room=None, sched=None, has_notification=True):
return Meeting(
id=i,
title=title,
@@ -30,6 +30,7 @@ def mk(i, title="T", room=None, sched=None):
created_by=1,
created_by_name="Roman",
created_at=now,
+ has_notification=has_notification,
)
@@ -110,6 +111,13 @@ def test_polling():
assert b4.poll_once() == 0 and len(tb.sent) == 1 # stale not posted
print("run4 (stale) announced 0 sent 1")
+ api._m.append(mk(6, title="Silent", has_notification=False))
+ b5 = MeetingsBot(cfg, api=api, bot=tb, store=StateStore(cfg.state_file))
+ b5.start()
+ assert b5.poll_once() == 0 and len(tb.sent) == 1 # no-notification not posted
+ assert 6 in b5.state.seen_meeting_ids
+ print("run5 (no notification) announced 0 sent 1")
+
print("ALL GOOD")
diff --git a/bots/meetings_telegram_bot/README.md b/bots/meetings_telegram_bot/README.md
index 4132213..274e033 100644
--- a/bots/meetings_telegram_bot/README.md
+++ b/bots/meetings_telegram_bot/README.md
@@ -49,6 +49,8 @@ Stop with `Ctrl-C`.
so it does not spam the group. Only meetings created afterwards are posted.
- The join link in each post opens the web app's room page, and only appears
when the meeting has a room.
+- Meetings created with the "Send a Telegram notification" checkbox unchecked
+ are marked seen but never posted, so they stay silent in the group.
## Optional: SOCKS5 proxy
diff --git a/bots/meetings_telegram_bot/api.py b/bots/meetings_telegram_bot/api.py
index 253e310..ad69ee1 100644
--- a/bots/meetings_telegram_bot/api.py
+++ b/bots/meetings_telegram_bot/api.py
@@ -34,6 +34,9 @@ class Meeting:
created_by: int
created_by_name: str
created_at: datetime | None
+ # Whether the meeting should be announced. Defaults to True so meetings from
+ # older API responses (which lack the field) are still announced.
+ has_notification: bool = True
@classmethod
def from_json(cls, data: dict[str, Any]) -> "Meeting":
@@ -46,6 +49,7 @@ class Meeting:
created_by=int(data.get("createdBy", 0) or 0),
created_by_name=str(data.get("createdByName") or ""),
created_at=_parse_rfc3339(data.get("createdAt")),
+ has_notification=bool(data.get("hasNotification", True)),
)
diff --git a/bots/meetings_telegram_bot/bot.py b/bots/meetings_telegram_bot/bot.py
index f0cffcb..a2a2a12 100644
--- a/bots/meetings_telegram_bot/bot.py
+++ b/bots/meetings_telegram_bot/bot.py
@@ -77,6 +77,11 @@ class MeetingsBot:
announced = 0
for meeting in self._new_meetings(meetings):
+ if not meeting.has_notification:
+ self.state.seen_meeting_ids.add(meeting.id)
+ log.info("skipping meeting %s: notifications disabled", meeting.id)
+ continue
+
if self._is_stale(meeting):
self.state.seen_meeting_ids.add(meeting.id)
log.info("skipping stale meeting %s", meeting.id)
diff --git a/frontend/src/pages/PlanMeetingPage.jsx b/frontend/src/pages/PlanMeetingPage.jsx
index dd1a629..0333939 100644
--- a/frontend/src/pages/PlanMeetingPage.jsx
+++ b/frontend/src/pages/PlanMeetingPage.jsx
@@ -20,6 +20,9 @@ export default function PlanMeetingPage({ onCreated, onCancel }) {
// When checked the author is recorded as joining straight away. Checked by
// default, since planning a meeting usually means you intend to attend.
const [autoJoin, setAutoJoin] = useState(true)
+ // When checked the Telegram bot announces the meeting. Checked by default;
+ // users uncheck it to create a meeting silently.
+ const [hasNotification, setHasNotification] = useState(true)
const [saving, setSaving] = useState(false)
const [error, setError] = useState('')
@@ -42,6 +45,7 @@ export default function PlanMeetingPage({ onCreated, onCancel }) {
// instant the backend expects.
scheduledAt: new Date(scheduledAt).toISOString(),
autoJoin,
+ hasNotification,
})
onCreated?.()
} catch (err) {
@@ -102,6 +106,14 @@ export default function PlanMeetingPage({ onCreated, onCancel }) {
/>
I will join this meeting
+