cloudfunctions

package module
v0.0.0-...-628cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

README

Candidate Email Sync

candidate_email_sync is an HTTP triggered cloud function for syncing a user's inbox to a start and end date. It is used to do an initial one-time historic sync for new users and future syncs if a user's account is inactive for over a week.

candidate_email_sync blindly syncs emails to the inputted start date, which makes it convenient for manual DevOps tasks that require re-syncing a user's inbox.

SelfDoc

Auto-generated code documentation to make the repository easier to navigate and contribute to.

Last Updated: 2023-05-15

The candidate_email_sync directory is for a Cloud Function package that syncs candidate emails. It includes a README file with a brief overview of the function's purpose, a configuration file for golangci-lint, a file with functions that fetch threads of emails from a Gmail account and filter them based on certain criteria, a file with unit tests for those functions, a file that specifies the module name, Go version, and dependencies required for the function to run, and a file with the Cloud Function package that imports various packages, including pubsub, gmail, and sentry-go.

Files
.golangci.yml

This file contains the configuration for golangci-lint, a tool used to run various linters on Go code. It includes a list of regex patterns to exclude from the linting process, with an example of excluding a specific issue related to loop variables being captured by a function literal.

cloudfunction.go

This file contains a Cloud Function package that syncs candidate emails. It imports various packages, including pubsub, gmail, and sentry-go. The handler function initializes the CloudFunction struct, sets up error handling and logging using Sentry, reads the request body, and calls the Sync method. The Sync() function fetches and processes new emails from Gmail using batch processing and waits for all messages to be processed before returning. Additionally, the file contains a function PublishMessages that publishes Gmail messages to a Pub/Sub topic.

email.go

This file contains functions that fetch threads of emails from a Gmail account and filter them based on certain criteria. The fetchThreadsSinceDate function fetches all threads since a given start date, ignoring threads of only sent emails and threads already processed by SRC. The skipThread function skips threads that have already been labeled with the SRC label, and the filterMessagesAfterReply function filters messages in a thread to only include those that were sent after a reply.

email_test.go

This file contains unit tests for the skipThread and filterMessagesAfterReply functions in the email.go file. The tests cover different scenarios and use the testing package and the google.golang.org/api/gmail/v1 package.

go.mod

This file specifies the module name, Go version, and dependencies required for the candidate_email_sync cloud function to run, including packages such as cloud.google.com/go/pubsub, github.com/GoogleCloudPlatform/functions-framework-go, github.com/getsentry/sentry-go, github.com/shared-recruiting-co/shared-recruiting-co/libs/src, and google.golang.org/api.

go.sum

This file contains a list of dependencies and their specific versions, as well as cryptographic checksums for the modules used in the cloudfunctions/candidate_email_sync directory, ensuring the integrity of the downloaded modules.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudFunction

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

func NewCloudFunction

func NewCloudFunction(ctx context.Context, payload EmailSyncRequest) (*CloudFunction, error)

func (*CloudFunction) PublishMessages

func (cf *CloudFunction) PublishMessages(messages []*gmail.Message) (*pubsub.PublishResult, error)

func (*CloudFunction) Sync

func (cf *CloudFunction) Sync() error

type EmailSyncRequest

type EmailSyncRequest struct {
	Email string `json:"email"`
	// StartDate is the date to start syncing from (inclusive)
	StartDate time.Time `json:"start_date"`
	// EndDate is optional
	// if not provided, it will default to the current time
	EndDate  time.Time                    `json:"end_date"`
	Settings schema.EmailMessagesSettings `json:"settings"`
}

Jump to

Keyboard shortcuts

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