Sha256: e4a7beeab1c532b5d866c686b3d5f6319e50b01c64a80b9ec233e6a091157f5a

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

#------------------------------------------------------------------------
# Gurgitate rules for the mail proxy
# 
# I (hopefully) get some ActiveRecord gubbins in as well as the Gurgitate
# stuff.
#------------------------------------------------------------------------

# ------------------------------------------------------------------------
# mail to mailing list
# ------------------------------------------------------------------------
to.each do |to_address|
    $logger.debug "Looking up #{to_address}"
    if mlinfo = Mailinglist.find_by_address(to_address)
        $logger.debug "mlinfo is #{mlinfo.inspect}"
        ml, command, *params = mlinfo

        $logger.debug ml.inspect
        $logger.debug command.inspect

        case command
        when :mail
            mess=Message.from_message(self)
            mess.mailinglist = ml
            mess.save!

            if mess then
                mess.deliver

                if ml.archived?
                    mess.save
                    ml.store_message mess
                    ml.save
                else
                    mess.destroy
                end
            end
        when :request
            ml.handle_request self
        when :bounces
            nil # yes, this needs to be handled
        when :proxy
            # later
        end
        return
    else
        matches = to_address.match(/(.*?)#(.*?)@(.*)/)
        $logger.debug "hey, found a funky rewrite thingy"

        if matches then
            proxy_address=Address.proxyaddress(from)
            $logger.debug "proxy address is: #{proxy_address.inspect}"
            if proxy_address
                mess=Message.from_message(self)
                
                mess.mailinglist = Mailinglist.find_by_address(proxy_address)[0]
                mess.deliver 
            end
        end
        # bounce, or report to postmaster, or something
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sugoi-mail-0.3.2 lib/gurgitate-rules.rb