Auto-commit 2026-04-27 19:13

This commit is contained in:
2026-04-27 19:13:03 -04:00
parent c1fc21702c
commit 35d47733ea
10 changed files with 915 additions and 119 deletions

View File

@@ -5,12 +5,14 @@ import (
"fmt"
"os"
"path/filepath"
"sync"
"time"
"github.com/frenocorp/pop/internal/config"
)
type ContactManager struct {
mu sync.Mutex
configDir string
contactsFile string
}
@@ -25,6 +27,8 @@ func NewContactManager() *ContactManager {
}
func (m *ContactManager) List(req ListContactsRequest) (*ListContactsResponse, error) {
m.mu.Lock()
defer m.mu.Unlock()
contacts, err := m.loadContacts()
if err != nil {
return nil, err
@@ -60,6 +64,8 @@ func (m *ContactManager) List(req ListContactsRequest) (*ListContactsResponse, e
}
func (m *ContactManager) Create(req CreateContactRequest) (*Contact, error) {
m.mu.Lock()
defer m.mu.Unlock()
contacts, err := m.loadContacts()
if err != nil {
return nil, err
@@ -88,6 +94,8 @@ func (m *ContactManager) Create(req CreateContactRequest) (*Contact, error) {
}
func (m *ContactManager) Get(id string) (*Contact, error) {
m.mu.Lock()
defer m.mu.Unlock()
contacts, err := m.loadContacts()
if err != nil {
return nil, err
@@ -103,6 +111,8 @@ func (m *ContactManager) Get(id string) (*Contact, error) {
}
func (m *ContactManager) Update(id string, req UpdateContactRequest) (*Contact, error) {
m.mu.Lock()
defer m.mu.Unlock()
contacts, err := m.loadContacts()
if err != nil {
return nil, err
@@ -145,6 +155,8 @@ func (m *ContactManager) Update(id string, req UpdateContactRequest) (*Contact,
}
func (m *ContactManager) Delete(id string) error {
m.mu.Lock()
defer m.mu.Unlock()
contacts, err := m.loadContacts()
if err != nil {
return err