application

package
v0.0.0-...-c4b140d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPullCompleted = errors.New("pull completed")
View Source
var ErrSourceReadCompleted = errors.New("source read completed")

Functions

func NewContactSearchService

func NewContactSearchService(contactSearch ContactSearch, unifiedRepo repository.IUnified) *contactSearchService

func NewContactService

func NewContactService(
	userRepo repository.IUser,
	defaultSourceContactRepo repository.IContact,
	unifiedRepo repository.IUnified,
	unifiedContactSyncer IUnifiedSyncer,
	contactSourceProvider IContactSourceProvider,
) *contactService

func NewNoteService

func NewNoteService(noteRepo repository.INote) *noteService

func NewTagService

func NewTagService(tagRepo repository.ITag) *tagService

func NewUserService

func NewUserService(userRepo repository.IUser) *userService

Types

type ContactSearch

type ContactSearch interface {
	Search(userId domain.UserID, searchParams domain.SearchParams) (docs []domain.UnifiedSearch, err error)
}

type ContactSearchService

type ContactSearchService interface {
	SearchContacts(ctx context.Context, userId domain.UserID, searchDto models.SearchContactDto) (unified []*models.Unified, err error)
}

type ContactService

type ContactService interface {
	SaveContact(context.Context, domain.UserID, *models.CreateContactDto) (updated *models.Unified, err error)
	UpdateContact(context.Context, domain.UserID, domain.UnifiedId, *models.UpdateUnifiedDto) (*models.Unified, error)
	UpdateCategory(ctx context.Context, userId domain.UserID, role *domain.Role, unifiedId domain.UnifiedId, category domain.ContactCatgeory) (*models.Unified, error)
	GetContacts(ctx context.Context, id domain.UserID, limit int, lastDocumentId *domain.ContactID) ([]*models.Contact, error)
	GetContactByID(context.Context, domain.UserID, domain.UnifiedId) (*models.Unified, error)
	DeleteContact(context.Context, domain.UserID, domain.UnifiedId) error
}

type ContactSourceDeletedPublisher

type ContactSourceDeletedPublisher interface {
	Publish(ctx context.Context, job jobModels.ContactSourceDeleted) (err error)
}

type ContactSourceService

type ContactSourceService struct {
	// contains filtered or unexported fields
}

func NewContactSourceService

func NewContactSourceService(
	googleOAuthService GoogleOAuthService,
	contactSourceRepo repository.IContactSource,
	pullContactSourcePublisher PullContactPublisher,
	unifiedContactSyncer IUnifiedSyncer,
	userRepo repository.IUser,
	contactSourceProvider IContactSourceProvider,
	unifiedRepo repository.IUnified,
	contactSourceDeletedPublisher ContactSourceDeletedPublisher,
) *ContactSourceService

func (*ContactSourceService) DeleteContactSource

func (s *ContactSourceService) DeleteContactSource(ctx context.Context, userId domain.UserID, sourceId domain.ContactSourceID, removeContactsFromUnified bool) (err error)

func (*ContactSourceService) GetAllContactSources

func (s *ContactSourceService) GetAllContactSources(ctx context.Context, userId domain.UserID) (sources []*models.ContactSource, err error)

func (*ContactSourceService) GetContactSources

func (s *ContactSourceService) GetContactSources(ctx context.Context, userId domain.UserID, limit int, lastDocumentId *domain.ContactSourceID) (sources []*models.ContactSource, err error)

func (*ContactSourceService) GetGoogleRedirectUrl

func (s *ContactSourceService) GetGoogleRedirectUrl(ctx context.Context) (url string, err error)

func (*ContactSourceService) LinkGoogleContactSource

func (s *ContactSourceService) LinkGoogleContactSource(ctx context.Context, userId domain.UserID, role *domain.Role, code string) (err error)

func (*ContactSourceService) OnDeleteContactSource

func (s *ContactSourceService) OnDeleteContactSource(ctx context.Context, userId domain.UserID, sourceId domain.ContactSourceID, source domain.Source, removeContactsFromUnified bool) (err error)

func (*ContactSourceService) PullContacts

func (s *ContactSourceService) PullContacts(ctx context.Context) (err error)

func (*ContactSourceService) SyncContacts

func (s *ContactSourceService) SyncContacts(ctx context.Context, userId domain.UserID, sourceId domain.ContactSourceID) (err error)

type CsvImporter

type CsvImporter struct {
	// contains filtered or unexported fields
}

func NewCsvImporter

func NewCsvImporter(defaultContactsRepo *firestore.DefaultContactsFirestore, unifiedContactSyncer IUnifiedSyncer) *CsvImporter

func (*CsvImporter) Import

func (importer *CsvImporter) Import(ctx context.Context, reader io.Reader, userId domain.UserID) (err error)

type GoogleOAuthService

type GoogleOAuthService interface {
	GetRedirectUrl(ctx context.Context) (url string, err error)
	GetToken(ctx context.Context, code string) (token *oauth2.Token, err error)
	GetUserInfo(ctx context.Context, accessToken string) (info *googleOAuth2.Tokeninfo, err error)
	GetConfig() (config *oauth2.Config)
}

type IContactSource

type IContactSource interface {
	Update(ctx context.Context, userId domain.UserID, sourceId domain.ContactSourceID, contactId domain.ContactID, unified domain.Unified) (err error)

	// puller return a new contacts puller.
	Puller(ctx context.Context, userId domain.UserID, source domain.ContactSource) (puller IContactSourcePuller)

	// reader returns a reader instance to read all documents stored in the database (and not from the remote. ie google, outlook etc) for a source.
	Reader(ctx context.Context, userId domain.UserID, sourceId domain.ContactSourceID) IContactSourceReader

	// Remove() will remove contacts from database (and not from the remote, ie google, outlook etc). This is invoked when a contact source is removed.
	Remove(ctx context.Context, userId domain.UserID, sourceId domain.ContactSourceID, contactIds []domain.ContactID) (err error)
}

type IContactSourceProvider

type IContactSourceProvider interface {
	Get(source domain.Source) IContactSource
}

type IContactSourcePuller

type IContactSourcePuller interface {
	Pull(ctx context.Context) (newContacts []domain.Contact, updatedContacts []domain.Contact, deletedContacts []domain.Contact, err error)
}

puller returns contacts from a source. Contacts are converted to domain.Contact. Pull should be called continuosly until it returns err == ErrPullCompleted (which is the normal termination) or some other error.

type IContactSourceReader

type IContactSourceReader interface {
	Read(ctx context.Context) (contacts []domain.Contact, err error)
}

reader returns contacts stored for a source from the database. Contacts are converted to domain.Contact. Read should be called continuosly until it returns err == ErrSourceReadCompleted (which is the normal termination) or some other error.

type ICsvImporter

type ICsvImporter interface {
	Import(ctx context.Context, reader io.Reader, userId domain.UserID) (err error)
}

type ILinkSuggestionService

type ILinkSuggestionService interface {

	// check for existing link suggestion and append to matches
	CheckAndAddToLinkSuggestion(ctx context.Context, userId domain.UserID, unified domain.Unified) (added bool, err error)

	// create new link suggestions if any
	CheckAndCreateLinkSuggestion(ctx context.Context, userId domain.UserID, unified domain.Unified) (added bool, err error)

	GetLinkSuggestions(ctx context.Context, uID domain.UserID, limit int, lastDocumentId *domain.LinkSuggestionID) ([]*models.LinkSuggestion, error)

	ApplyLinkSuggestion(ctx context.Context, uID domain.UserID, suggestionId domain.LinkSuggestionID, request []domain.UnifiedId) (err error)
}

type IUnifiedContactService

type IUnifiedContactService interface {
	GetContacts(ctx context.Context, id domain.UserID, limit int, lastDocumentId *domain.UnifiedId) ([]*models.Unified, error)
	GetPendingContacts(ctx context.Context, id domain.UserID, limit int, lastDocumentInstant *time.Time, lastDocumentId *domain.UnifiedId) ([]*models.Unified, error)
	GetRecentContacts(ctx context.Context, uid domain.UserID, maxDays *int64, limit int, lastDocumentInstant *time.Time, lastDocumentId *domain.UnifiedId) ([]*models.Unified, error)
}

type IUnifiedSyncer

type IUnifiedSyncer interface {
	SyncContactToUnified(ctx context.Context, userId domain.UserID, source domain.Source, sourceId domain.ContactSourceID, contactId domain.ContactID, contact domain.Contact) (unified *domain.Unified, err error)
}

type LinkSuggestionService

type LinkSuggestionService struct {
	// contains filtered or unexported fields
}

func NewLinkSuggestionService

func NewLinkSuggestionService(unifiedRepo repository.IUnified, linkSuggestionRepo repository.ILinkSuggestion) *LinkSuggestionService

func (*LinkSuggestionService) AddToExistingSuggestion

func (s *LinkSuggestionService) AddToExistingSuggestion(ctx context.Context, userId domain.UserID, match domain.LinkMatch, key domain.LinkSuggestionKey, value string) (addedToExisting bool, err error)

AddToExistingSuggestion checks if suggestion already exists for a key-value pair key could be email, phone or name

func (*LinkSuggestionService) ApplyLinkSuggestion

func (a *LinkSuggestionService) ApplyLinkSuggestion(ctx context.Context, uID domain.UserID, suggestionId domain.LinkSuggestionID, ids []domain.UnifiedId) (err error)

func (*LinkSuggestionService) CheckAndAddToLinkSuggestion

func (s *LinkSuggestionService) CheckAndAddToLinkSuggestion(ctx context.Context, userId domain.UserID, unified domain.Unified) (added bool, err error)

func (*LinkSuggestionService) CheckAndCreateLinkSuggestion

func (s *LinkSuggestionService) CheckAndCreateLinkSuggestion(ctx context.Context, userId domain.UserID, unified domain.Unified) (added bool, err error)

Check for possible duplicates in unified collection and create suggestions if any

func (*LinkSuggestionService) CreateLinkSuggestion

func (s *LinkSuggestionService) CreateLinkSuggestion(ctx context.Context, userId domain.UserID, unified domain.Unified, matches []domain.Unified, key domain.LinkSuggestionKey, value string) (created *domain.LinkSuggestion, err error)

func (*LinkSuggestionService) GetLinkSuggestions

func (a *LinkSuggestionService) GetLinkSuggestions(ctx context.Context, uID domain.UserID, limit int, lastDocumentId *domain.LinkSuggestionID) ([]*models.LinkSuggestion, error)

type NoteService

type NoteService interface {
	SaveNote(context.Context, domain.UserID, domain.UnifiedId, *models.Note) (updated *models.Note, err error)
	UpdateNote(context.Context, domain.UserID, domain.UnifiedId, domain.NoteID, *models.Note) (*models.Note, error)
	GetAllNotes(context.Context, domain.UserID, domain.UnifiedId) ([]*models.Note, error)
	GetNotes(ctx context.Context, userID domain.UserID, contactId domain.UnifiedId, limit int, lastDocumentId *domain.NoteID) ([]*models.Note, error)
	DeleteNote(context.Context, domain.UserID, domain.UnifiedId, domain.NoteID) error
}

type PeopleService

type PeopleService interface {
	List(pageToken *string) (resp *people.ListConnectionsResponse, err error)
	Update(personId string, person *people.Person) (updated *people.Person, err error)
	Get(personId string) (person *people.Person, err error)
}

type PeopleServiceFactory

type PeopleServiceFactory interface {
	New(ctx context.Context, accessToken string, refreshToken string, expiry time.Time) (service PeopleService)
}

type PullContactPublisher

type PullContactPublisher interface {
	Publish(ctx context.Context, job jobModels.PullContactsRequest) (err error)
}

type TagService

type TagService interface {
	SaveTag(context.Context, domain.UserID, domain.UnifiedId, *models.Tag) (updated *models.Tag, err error)
	UpdateTag(context.Context, domain.UserID, domain.UnifiedId, domain.TagID, *models.Tag) (*models.Tag, error)
	GetAllTags(context.Context, domain.UserID, domain.UnifiedId) ([]*models.Tag, error)
	GetTags(ctx context.Context, userId domain.UserID, contactId domain.UnifiedId, limit int, lastDocumentId *domain.TagID) ([]*models.Tag, error)
	DeleteTag(context.Context, domain.UserID, domain.UnifiedId, domain.TagID) error
}

type UnifiedContactService

type UnifiedContactService struct {
	// contains filtered or unexported fields
}

func NewUnifiedContactService

func NewUnifiedContactService(unifiedRepo repository.IUnified, linkSuggestionService ILinkSuggestionService, contactLogRepo repository.IContactLog) *UnifiedContactService

func (*UnifiedContactService) GetContacts

func (a *UnifiedContactService) GetContacts(ctx context.Context, uID domain.UserID, limit int, lastDocumentId *domain.UnifiedId) ([]*models.Unified, error)

func (*UnifiedContactService) GetPendingContacts

func (a *UnifiedContactService) GetPendingContacts(ctx context.Context, uID domain.UserID, limit int, lastDocumentInstant *time.Time, lastDocumentId *domain.UnifiedId) (pending []*models.Unified, err error)

func (*UnifiedContactService) GetRecentContacts

func (a *UnifiedContactService) GetRecentContacts(ctx context.Context, uID domain.UserID, maxDays *int64, limit int, lastDocumentInstant *time.Time, lastDocumentId *domain.UnifiedId) (pending []*models.Unified, err error)

func (*UnifiedContactService) SyncContactToUnified

func (s *UnifiedContactService) SyncContactToUnified(ctx context.Context, userId domain.UserID, source domain.Source, sourceId domain.ContactSourceID, contactId domain.ContactID, contact domain.Contact) (createdUnified *domain.Unified, err error)

type UserService

type UserService interface {
	SaveUser(context.Context, domain.UserID, *models.User) (*models.User, error)
	UpdateUser(context.Context, domain.UserID, *models.User) (*models.User, error)
	GetUser(context.Context, domain.UserID) (*models.User, error)
	DeleteUser(context.Context, domain.UserID) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL