Coder Social home page Coder Social logo

sailplay-test's Introduction

Тестовое задание для python-разработчика. API для отправки Email

В коде приложения хотим уметь удобно (для разработчиков) отправлять письма, не думая о том, как внутри работает отправка письма и фильтрация контента.

Отправка письма происходит через внутренний сервис по HTTP API:

https://email-machine.internal/api/email-gate/{email-domain}/

(в рамках тестового задания не нужно делать сам сервис отправки),

где email-domain может быть:

  • gmail
  • yandex
  • mail

Если домен получателя не входит в список, использовать по умолчанию gmail.

Формат JSON запроса отправки письма через сервис:

{
    "email: "[email protected]",
    "content": "email content"
}

Фильтрация контента.

Если домен получателя:

  • gmail.com: удаляем все предложения, которые содержат слово offer.
  • yandex.ru: заменяем все картинки текстом ссылки на картинку, т.е. <img src="https://spam.org/pic1.png"/> => https://spam.org/pic1.png
  • mail.ru: заменяем у всех изображений расширение файла с gif на png, т.е. <img src="https://spam.org/pic1.gif" /> => <img src="https://spam.org/pic1.png" />

Хотим получить:

  1. Единую точку входа для отправки письма.
  2. Расширяемость на уровне правил фильтрации контента, т.к. правила часто дополняются, и их может быть больше чем одно.
  3. Расширяемость на уровне почтовых клиентов, т.к. список клиентов растет.

Ожидаем, что пользоваться API можно будет:

from messaging.email import Email

email = Email('[email protected]', 'Hello gmail! I have an offer for you.')
email.send()
>>> {'email': "[email protected]", 'Hello gmail!'}

email = Email('[email protected]', 'Hello yandex! I have an pic <img src="https://spam.org/pic1.png" /> for you.')
email.send()
>>> {'email': "[email protected]", 'Hello yandex! I have an pic https://spam.org/pic1.png for you.'}

email = Email('[email protected]', 'Hello mail! I have an pic <img src="https://spam.org/pic1.gif" /> for you.')
email.send()
>>> {'email': '[email protected]', 'Hello mail! I have an pic <img src="https://spam.org/pic1.png" /> for you.'}

email = Email('[email protected]', 'Hello another mail client! I have an offer for you.')
email.send()
>>> {'email': '[email protected]', 'Hello another mail client!'}

Реализацию задания выложить в репозиторий и предоставить ссылку.

sailplay-test's People

Contributors

retroraisins avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.