Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
feat(people): let a meeting participant point to a person
Guido Boyked879d32ee389
diff --git a/app/models/meeting_participant.rb b/app/models/meeting_participant.rbindex 7d981c3..691fbba 100644--- a/app/models/meeting_participant.rb+++ b/app/models/meeting_participant.rb@@ -37,6 +37,12 @@# fk_rails_... (user_id => users.id) ON DELETE => nullify#class MeetingParticipant < ApplicationRecord+ # The person row of the people directory this participant is (a contact+ # without an account; a member is found through user_id). Declared BEFORE+ # acts_as_tenant, which checks the tenant only of earlier references; the+ # validation below holds it to the participant's organisation on top.+ belongs_to :person, optional: true+acts_as_tenant(:organisation)belongs_to :meeting@@ -51,6 +57,7 @@ class MeetingParticipant < ApplicationRecord# rows are built directly (specs, console).validates :normalized_name, uniqueness: { scope: :meeting_id }, allow_blank: truevalidates :user_id, uniqueness: { scope: :meeting_id }, allow_nil: true+ validate :person_in_same_organisation, if: -> { person_id.present? && will_save_change_to_person_id? }# External (name-only) participants in the given projects — the ONE definition of# "an external participation eligible to be claimed", shared by the claim matcher@@ -89,4 +96,10 @@ class MeetingParticipant < ApplicationRecordself.display_name = display_name.to_s.strip.gsub(/\s+/, ' ') if display_name.present?self.normalized_name = self.class.normalize_name(display_name)end++ def person_in_same_organisation+ return if Person.where(id: person_id, organisation_id: organisation_id).exists?++ errors.add(:person, :invalid)+ endenddiff --git a/db/migrate/20261027120000_add_person_to_meeting_participants.rb b/db/migrate/20261027120000_add_person_to_meeting_participants.rbnew file mode 100644index 0000000..e700c45--- /dev/null+++ b/db/migrate/20261027120000_add_person_to_meeting_participants.rb@@ -0,0 +1,12 @@+# frozen_string_literal: true++# A meeting participant may point to a row of the people directory (Person),+# so a contact without an account has its meetings too. Nothing writes it yet;+# linking comes in a later step. Deleting a person keeps the participant and+# its display name.+class AddPersonToMeetingParticipants < ActiveRecord::Migration[8.1]+ def change+ add_reference :meeting_participants, :person, type: :uuid, null: true, index: true,+ foreign_key: { on_delete: :nullify }+ end+enddiff --git a/db/schema.rb b/db/schema.rbindex e7f3a4b..7782bb2 100644--- a/db/schema.rb+++ b/db/schema.rb@@ -10,7 +10,7 @@## It's strongly recommended that you check this file into your version control system.-ActiveRecord::Schema[8.1].define(version: 2026_10_26_120000) do+ActiveRecord::Schema[8.1].define(version: 2026_10_27_120000) do# These are extensions that must be enabled in order to support this databaseenable_extension "pg_catalog.plpgsql"enable_extension "pgcrypto"@@ -787,9 +787,11 @@ ActiveRecord::Schema[8.1].define(version: 2026_10_26_120000) dot.string "normalized_name", null: falset.datetime "created_at", null: falset.datetime "updated_at", null: false+ t.uuid "person_id"t.index ["meeting_id", "normalized_name"], name: "index_meeting_participants_on_meeting_id_and_normalized_name", unique: truet.index ["meeting_id", "user_id"], name: "index_meeting_participants_on_meeting_id_and_user_id", unique: true, where: "(user_id IS NOT NULL)"t.index ["organisation_id", "normalized_name"], name: "idx_on_organisation_id_normalized_name_5eadc4a5e5"+ t.index ["person_id"], name: "index_meeting_participants_on_person_id"t.index ["user_id"], name: "index_meeting_participants_on_user_id"end@@ -2058,6 +2060,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_10_26_120000) doadd_foreign_key "meeting_participant_claim_rejections", "users", on_delete: :cascadeadd_foreign_key "meeting_participants", "meetings"add_foreign_key "meeting_participants", "organisations"+ add_foreign_key "meeting_participants", "people", on_delete: :nullifyadd_foreign_key "meeting_participants", "users", on_delete: :nullifyadd_foreign_key "meeting_ticket_suggestion_runs", "chatposts", on_delete: :cascadeadd_foreign_key "meeting_ticket_suggestion_runs", "meetings", on_delete: :cascadediff --git a/spec/models/meeting_participant_spec.rb b/spec/models/meeting_participant_spec.rbindex 89c87b9..1d4b8da 100644--- a/spec/models/meeting_participant_spec.rb+++ b/spec/models/meeting_participant_spec.rb@@ -109,6 +109,41 @@ RSpec.describe MeetingParticipant, type: :model doendend+ # The people directory (S2a): a participant may point to a person row. Only+ # a person of the meeting's own organisation.+ describe 'person link' do+ it 'accepts a person of the same organisation' do+ person = ActsAsTenant.with_tenant(organisation) { create(:person, organisation: organisation) }+ valid = ActsAsTenant.with_tenant(organisation) { build(:meeting_participant, meeting: meeting, person: person).valid? }++ expect(valid).to be(true)+ end++ it 'refuses a person of another organisation' do+ other = create(:organisation)+ foreign = ActsAsTenant.with_tenant(other) { create(:person, organisation: other) }+ errors = ActsAsTenant.with_tenant(organisation) do+ participant = build(:meeting_participant, meeting: meeting, person_id: foreign.id)+ participant.valid?+ participant.errors.details[:person]+ end++ expect(errors).to include(error: :invalid)+ end++ it 'keeps the participant and its name when the person is deleted' do+ person = ActsAsTenant.with_tenant(organisation) { create(:person, organisation: organisation) }+ participant = ActsAsTenant.with_tenant(organisation) do+ create(:meeting_participant, meeting: meeting, person: person, display_name: 'Rita Rot')+ end++ ActsAsTenant.with_tenant(organisation) { person.destroy! }++ reloaded = ActsAsTenant.with_tenant(organisation) { described_class.find(participant.id) }+ expect([reloaded.person_id, reloaded.display_name]).to eq([nil, 'Rita Rot'])+ end+ end+describe 'user deletion (snapshot survives)' doit 'nulls user_id but keeps display_name when the linked user is deleted' douser = create(:user)