Coder Social home page Coder Social logo

Comments (2)

kaleb avatar kaleb commented on September 15, 2024

This is my view function in case anybody is curious:

def mail_read_tracker(request, encrypted):
    try:
        if not defaults.TRACK_ENABLE or not defaults.ENABLE_LOGGING:
            return
        mail_log_id = signing.loads(encrypted)
        mail_log = MailLog.objects.get(log_id=mail_log_id)
        req = MockRequest(request)
        ip_addr = get_ip(req)
        user_agent = req.META.get('HTTP_USER_AGENT')
        track_log = MailLogTrack.objects.filter(mail_log=mail_log, ip=ip_addr, ua=user_agent)
        if not track_log.exists():
            lat_lon = request.META.get('HTTP_X_APPENGINE_CITYLATLONG')
            lat, lon = lat_lon.split(',') if lat_lon else (None, None)
            MailLogTrack.objects.create(
                mail_log=mail_log,
                ip=ip_addr,
                ua=user_agent,
                ip_country_code=request.META.get('HTTP_X_APPENGINE_COUNTRY'),
                ip_region=request.META.get('HTTP_X_APPENGINE_REGION'),
                ip_city=request.META.get('HTTP_X_APPENGINE_CITY'),
                ip_latitude=lat,
                ip_longitude=lon,
                is_read=True,
            )
        else:
            track_log[0].save()
    finally:
        return HttpResponse(
            content=defaults.TRACK_PIXEL[1],
            content_type=defaults.TRACK_PIXEL[0],
        )

from django-db-mailer.

kaleb avatar kaleb commented on September 15, 2024

This would have also made #99 not necessary as well.

from django-db-mailer.

Related Issues (20)

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.