Add meetings panel to the rooms page, add checkbox for marking for autojoin
This commit is contained in:
1 parent
e9ad57524e
commit
f5f389f5d3
6 files changed
+101
-7
No files matched your search
@@ -21,8 +21,10 @@ func NewService(r *Repository) (*Service, error) {
|
||||
return &Service{r: r}, nil
|
||||
}
|
||||
|
||||
// Create validates and stores a new meeting authored by u.
|
||||
func (s *Service) Create(ctx context.Context, u *user.User, title, intent, room string, scheduledAt time.Time) (*Meeting, 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) {
|
||||
if u == nil {
|
||||
slog.Error("nil user", slog.String("op", "service.Create"))
|
||||
return nil, ErrInternal
|
||||
@@ -47,6 +49,13 @@ func (s *Service) Create(ctx context.Context, u *user.User, title, intent, room
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Optionally record the author's own "join" vote straight away.
|
||||
if autoJoin {
|
||||
if err := s.r.UpsertVote(ctx, created.Id, u.Id, VoteJoin); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Re-read so the response carries the author name and vote aggregates.
|
||||
return s.r.MeetingById(ctx, u.Id, created.Id)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ type createMeetingRequest struct {
|
||||
Intent string `json:"intent"`
|
||||
Room string `json:"room"`
|
||||
ScheduledAt string `json:"scheduledAt"`
|
||||
// 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"`
|
||||
}
|
||||
|
||||
type voteMeetingRequest struct {
|
||||
@@ -68,7 +71,7 @@ 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)
|
||||
created, err := h.meetings.Create(r.Context(), u, req.Title, req.Intent, req.Room, scheduledAt, req.AutoJoin)
|
||||
if err != nil {
|
||||
h.fail(w, err)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user