Пример #1
0
func NewRedir(srv string) *Redir {
	// Instantiate our MaildIRC abstraction obj
	normname := formatservername(srv)
	var d maildir.Dir = maildir.Dir(normname)

	if !exists(normname) {
		fmt.Printf("creating maildir (%s) \n", normname)
		err := d.Create()
		if err != nil {
			log.Fatal(err)
		}
	}

	host := strings.Split(srv, ":")
	m := &Redir{
		Server:  host[0],
		Maildir: d,
	}
	return m
}
Пример #2
0
//TODO This may be more channel (ID) independent and better in some polling piece especially when we add the boltdb caching
func (s *inmemService) sortUnreadNotes() error {
	// Perform a sweep to collect new unread messages

	d := maildir.Dir(s.mdirpath)
	keys, kerr := d.Unseen()
	if kerr != nil {
		return kerr
	}
	for _, v := range keys {
		m, merr := d.Message(v)
		if merr != nil {
			return merr
		}
		i, nerr := newNoteEntry(m.Header, m.Body)
		if nerr != nil {
			return nerr
		}
		_ = d.SetFlags(v, "S")
		//todo combine adjacent notes by same author
		////a, nid = s.concatNoteEntry(a, i)
		s.n[i.ID] = i

		var err error
		cid := fmt.Sprintf("%v.%v", i.Attributes.host, i.Attributes.channel)
		ch, ok := s.h[cid]
		if !ok {
			ch, err = s.addChannel(i, cid)
			if err != nil {
				return err
			}
		}

		ch.Relationships.Notes.keys = append(ch.Relationships.Notes.keys, i.ID)
		s.h[cid] = ch
	}
	return nil
}