Files
Abhinav Raut bfbcd0a885 add contact deletion and data export for GDPR compliance
First part of GDPR support (#244): the right to erasure and the right
to access.

- DELETE /api/v1/contacts/{id} permanently deletes a contact or
  visitor. Conversations, messages, notes, and participants go with it
  via DB cascades. The avatar file is removed too.
- GET /api/v1/contacts/{id}/export downloads a JSON file with
  everything stored about the contact: profile, custom attributes, and
  all conversations with their messages. Private notes stay internal.
- Both actions are gated by new permissions (contacts:delete,
  contacts:export), granted to Admin in migration v2.6.0, and recorded
  in the activity log with actor and IP.
- Contact page gets Export data and Delete contact buttons, with a
  confirm dialog for delete.
- The unlinked media cleaner now also removes attachment files whose
  message no longer exists. Before this, deleting a conversation left
  its attachments on disk forever.
2026-07-14 01:30:59 +05:30

32 lines
1.2 KiB
Go

package models
import (
"time"
)
const (
AgentLogin = "agent_login"
AgentLogout = "agent_logout"
AgentAway = "agent_away"
AgentAwayReassigned = "agent_away_reassigned"
AgentOnline = "agent_online"
AgentPasswordSet = "agent_password_set"
AgentRolePermissionsChanged = "agent_role_permissions_changed"
ContactDeleted = "contact_deleted"
ContactDataExported = "contact_data_exported"
)
type ActivityLog struct {
ID int64 `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
ActivityType string `db:"activity_type" json:"activity_type"`
ActivityDescription string `db:"activity_description" json:"activity_description"`
ActorID int `db:"actor_id" json:"actor_id"`
TargetModelType string `db:"target_model_type" json:"target_model_type"`
TargetModelID int `db:"target_model_id" json:"target_model_id"`
IP string `db:"ip" json:"ip"`
Total int `db:"total" json:"-"`
}