Commit acbe64f7 authored by putro's avatar putro
Browse files

added newsletter to resources

parent ff91ef92
Pipeline #3890 passed with stages
in 5 minutes and 58 seconds
......@@ -215,6 +215,55 @@ func (h *mailingListResourceHandler) SearchQuery() *queryTemplate {
// Newsletter resource.
type newsletterResourceHandler struct {
baseDN string
func (h *newsletterResourceHandler) MakeDN(_ *as.User, rsrc *as.Resource) (string, error) {
rdn := replaceVars("listName=${resource}", templateVars{"resource": rsrc.Name})
return joinDN(rdn, "ou=Newsletters", h.baseDN), nil
func (h *newsletterResourceHandler) GetOwner(rsrc *as.Resource) string {
// No exclusive owners for newsletters.
return ""
func (h *newsletterResourceHandler) FromLDAP(entry *ldap.Entry) (*as.Resource, error) {
if !isObjectClass(entry, "mailingList") {
return nil, errWrongObjectClass
listName := entry.GetAttributeValue("listName")
return &as.Resource{
ID: as.ResourceID(entry.DN),
Type: as.ResourceTypeNewsletter,
Name: listName,
Newsletter: &as.Newsletter{
Public: s2b(entry.GetAttributeValue("public")),
Admins: entry.GetAttributeValues("listOwner"),
}, nil
func (h *newsletterResourceHandler) ToLDAP(rsrc *as.Resource) []ldap.PartialAttribute {
return []ldap.PartialAttribute{
{Type: "objectClass", Vals: []string{"top", "mailingList"}},
{Type: "listName", Vals: s2l(rsrc.Name)},
{Type: "public", Vals: s2l(b2s(rsrc.Newsletter.Public))},
{Type: "listOwner", Vals: rsrc.Newsletter.Admins},
func (h *newsletterResourceHandler) SearchQuery() *queryTemplate {
return &queryTemplate{
Base: joinDN("ou=Newsletters", h.baseDN),
Filter: "(&(objectClass=mailingList)(listName=${resource}))",
Scope: ldap.ScopeSingleLevel,
// Website (subsite) resource.
type websiteResourceHandler struct {
baseDN string
......@@ -458,6 +507,7 @@ func newDefaultResourceRegistry(baseDN string) *resourceRegistry {
reg := newResourceRegistry()
reg.register(as.ResourceTypeEmail, &emailResourceHandler{baseDN: baseDN})
reg.register(as.ResourceTypeMailingList, &mailingListResourceHandler{baseDN: baseDN})
reg.register(as.ResourceTypeNewsletter, &newsletterResourceHandler{baseDN: baseDN})
reg.register(as.ResourceTypeDAV, &webdavResourceHandler{baseDN: baseDN})
reg.register(as.ResourceTypeWebsite, &websiteResourceHandler{baseDN: baseDN})
reg.register(as.ResourceTypeDomain, &domainResourceHandler{baseDN: baseDN})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment