mirror of
				https://github.com/abhinavxd/libredesk.git
				synced 2025-11-04 14:03:19 +00:00 
			
		
		
		
	chore(imap-logs): add more context to error logs
This commit is contained in:
		@@ -198,15 +198,14 @@ func (e *Email) processEnvelope(ctx context.Context, client *imapclient.Client,
 | 
				
			|||||||
	inboxEmail, err := stringutil.ExtractEmail(inboxFromAddress)
 | 
						inboxEmail, err := stringutil.ExtractEmail(inboxFromAddress)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		e.lo.Error("error extracting email from inbox address", "inbox_from_address", inboxFromAddress, "error", err)
 | 
							e.lo.Error("error extracting email from inbox address", "inbox_from_address", inboxFromAddress, "error", err)
 | 
				
			||||||
		return fmt.Errorf("extracting email from inbox address: %w", err)
 | 
							return fmt.Errorf("extracting email from inbox address (%s): %w", inboxFromAddress, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if strings.EqualFold(fromEmail, inboxEmail) {
 | 
						if strings.EqualFold(fromEmail, inboxEmail) {
 | 
				
			||||||
		e.lo.Info("ignoring incoming message from inbox address", "message_id", env.MessageID, "from_email", fromEmail, "inbox_email", inboxEmail)
 | 
							e.lo.Info("ignoring incoming message from inbox address", "message_id", env.MessageID, "from_email", fromEmail, "inbox_email", inboxEmail)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Check if the message already exists in the database.
 | 
						// If message already exists in the database, ignore it.
 | 
				
			||||||
	// If it does, ignore it.
 | 
					 | 
				
			||||||
	exists, err := e.messageStore.MessageExists(env.MessageID)
 | 
						exists, err := e.messageStore.MessageExists(env.MessageID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		e.lo.Error("error checking if message exists", "message_id", env.MessageID)
 | 
							e.lo.Error("error checking if message exists", "message_id", env.MessageID)
 | 
				
			||||||
@@ -220,8 +219,8 @@ func (e *Email) processEnvelope(ctx context.Context, client *imapclient.Client,
 | 
				
			|||||||
	if contact, err := e.userStore.GetContact(0, fromEmail); err != nil {
 | 
						if contact, err := e.userStore.GetContact(0, fromEmail); err != nil {
 | 
				
			||||||
		envErr, ok := err.(envelope.Error)
 | 
							envErr, ok := err.(envelope.Error)
 | 
				
			||||||
		if !ok || envErr.ErrorType != envelope.NotFoundError {
 | 
							if !ok || envErr.ErrorType != envelope.NotFoundError {
 | 
				
			||||||
			e.lo.Error("error checking if user is blocked", "email", fromEmail, "error", err)
 | 
								e.lo.Error("error checking if contact is blocked", "email", fromEmail, "error", err)
 | 
				
			||||||
			return fmt.Errorf("checking if user is blocked: %w", err)
 | 
								return fmt.Errorf("checking if contact is blocked: %w", err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else if !contact.Enabled {
 | 
						} else if !contact.Enabled {
 | 
				
			||||||
		e.lo.Info("contact is blocked, ignoring message", "email", fromEmail)
 | 
							e.lo.Info("contact is blocked, ignoring message", "email", fromEmail)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user