Class: ProxyLink

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/proxy_link.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.real_address(addrstr) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/proxy_link.rb', line 11

def self.real_address(addrstr)
    matches=addrstr.match(/(.+)-([\d]+)@(.*)/)
    if matches
        mlname, proxyid, domainname = matches[1..3]
        domain=Domain.find_by_name domainname
        if domain
            ml=Mailinglist.find_all_by_name(mlname).find do |m|
                m.domain.id == domain.id
            end
            if ml
                # find_by_id instead of find so that it returns
                # nil if not found rather than raising an exception
                pl=self.find_by_id proxyid.to_i
                if pl
                    if pl.mailinglist_id == ml.id then
                        return pl.address.address
                    end
                end
            end
        end
    end
end

Instance Method Details

#proxy_addressObject



7
8
9
# File 'app/models/proxy_link.rb', line 7

def proxy_address
    "#{mailinglist.name}-#{id}@#{mailinglist.domain.name}"
end