且听疯吟 如此生活三十年
ejabberd-MAM

MAM - Message Archive Management

1. Message Archive

  • Archiving

    archived tag
    <message to='[email protected]/balcony'
      from='[email protected]/orchard'
      type='chat'>
      <body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>
      <archived by='[email protected]' id='28482-98726-73623' />
    </message>
    

2. Querying

  • Filtering

    • by jid
      <iq type='get' id='juliet1'>
        <query xmlns='urn:xmpp:mam:tmp'>
          <with>[email protected]</with>
        </query>
      </iq>
      
    • by time
      <iq type='get' id='juliet1'>
        <query xmlns='urn:xmpp:mam:tmp'>
            <start>2010-06-07T00:00:00Z</start>
            <end>2010-07-07T13:23:54Z</end>
        </query>
      </iq>
      
    • by max number
    • by uid of message
    <iq type='get' id='q29303'>
      <query xmlns='urn:xmpp:mam:tmp'>
          <start>2010-08-07T00:00:00Z</start>
          <set xmlns='http://jabber.org/protocol/rsm'>
             <max>10</max>
             <after>09af3-cc343-b409f</after>
          </set>
      </query>
    </iq>
    
    <message id='aeb213' to='[email protected]/chamber'>
      <result xmlns='urn:xmpp:mam:tmp' queryid='f27' id='28482-98726-73623'>
        <forwarded xmlns='urn:xmpp:forward:0'>
          <delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:08:25Z'/>
          <message to='[email protected]/balcony'
            from='[email protected]/orchard'
            type='chat'>
            <body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>
          </message>
        </forwarded>
      </result>
    </message>
    
    <message id='aeb214' to='[email protected]/chamber'>
      <result xmlns='urn:xmpp:mam:tmp' queryid='f27' id='5d398-28273-f7382'>
        <forwarded xmlns='urn:xmpp:forward:0'>
          <delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:09:32Z'/>
          <message to='[email protected]/orchard'
             from='[email protected]/balcony'
             type='chat' id='8a54s'>
            <body>What man art thou that thus bescreen'd in night so stumblest on my counsel?</body>
          </message>
        </forwarded>
      </result>
    </message>
    

3. Preferences

  • jid list

     <iq type='set' id='juliet2'>
        <prefs xmlns='urn:xmpp:mam:tmp' default='roster'>
          <always>
            <jid>[email protected]</jid>
          </always>
          <never>
            <jid>[email protected]</jid>
          </never>
        </prefs>
      </iq>
    
    • option:
      • always - all messages are archived by default.
      • never - messages are never archived by default.
      • roster - messages are archived only if the contact’s bare JID is in the user’s roster
    • rules:
      • outgoing - use ’to’ attribute
      • incomming - use ‘from’ attribute
      • contains resource - compare
      • no resource - any resource
  • Ad-Hoc Commands

    http://xmpp.org/extensions/xep-0050.html

4. Security

  • archived tag
  • only user authorized have permission
  • privacy

5. MongooseIM Config (odbc)

  • {mod_mam, []}
    enable mam
  • {mod_mam_odbc_prefs, [pm]}
    archiving preferences
    pm : user-to-user messages
    muc : multiple user
  • {mod_mam_odbc_user, [pm, muc]}
    converting an archive id to an integer
  • {mod_mam_odbc_arch, [pm, muc]}
    archiving message
  • mod_mam_odbc_async_writer
    Asynchronous writer, will insert batches of messages.
    option no_writer set in mod_mam_odbc_arch