annotate mod_storage_mongodb/mod_storage_mongodb.lua @ 1324:853a382c9bd6

mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
author Kim Alvefur <zash@zash.se>
date Fri, 28 Feb 2014 15:36:06 +0100
parents fd420237a5e4
children b21236b6b8d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
1 local next = next;
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
2 local setmetatable = setmetatable;
1324
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
3 local set = require"util.set";
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
4 local it = require"util.iterators";
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
5 local array = require"util.array";
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
6
507
46f578da4ff0 mod_storage_mongodb: assert the configuration options
James Callahan <james@chatid.com>
parents: 506
diff changeset
7 local params = assert ( module:get_option("mongodb") , "mongodb configuration not found" );
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
8
509
bf2ad6d6c778 mod_storage_mongodb: (un)lock globals around require; only auth if we need to
James Callahan <james@chatid.com>
parents: 508
diff changeset
9 prosody.unlock_globals();
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
10 local mongo = require "mongo";
509
bf2ad6d6c778 mod_storage_mongodb: (un)lock globals around require; only auth if we need to
James Callahan <james@chatid.com>
parents: 508
diff changeset
11 prosody.lock_globals();
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
12
1010
fd420237a5e4 mod_storage_mongodb: Use util.json to encode our data (handles non-string table keys, etc).
Waqas Hussain <waqas20@gmail.com>
parents: 813
diff changeset
13 local json = require "util.json";
fd420237a5e4 mod_storage_mongodb: Use util.json to encode our data (handles non-string table keys, etc).
Waqas Hussain <waqas20@gmail.com>
parents: 813
diff changeset
14
508
9831506dcfd6 mod_storage_mongodb: move database connecting to inside driver:open
James Callahan <james@chatid.com>
parents: 507
diff changeset
15 local conn
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
16
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
17 local keyval_store = {};
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
18 keyval_store.__index = keyval_store;
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
19
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
20 function keyval_store:get(username)
506
0e07810550c8 mod_storage_mongodb: Use _global as host when none provided
James Callahan <james@chatid.com>
parents: 505
diff changeset
21 local host = module.host or "_global";
0e07810550c8 mod_storage_mongodb: Use _global as host when none provided
James Callahan <james@chatid.com>
parents: 505
diff changeset
22 local store = self.store;
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
23
507
46f578da4ff0 mod_storage_mongodb: assert the configuration options
James Callahan <james@chatid.com>
parents: 506
diff changeset
24 -- The database name can't have a period in it (hence it can't be a host/ip)
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
25 local namespace = params.dbname .. "." .. host;
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
26 local v = { _id = { store = store ; username = username } };
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
27
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
28 local cursor , err = conn:query ( namespace , v );
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
29 if not cursor then return nil , err end;
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
30
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
31 local r , err = cursor:next ( );
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
32 if not r then return nil , err end;
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
33 return r.data;
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
34 end
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
35
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
36 function keyval_store:set(username, data)
506
0e07810550c8 mod_storage_mongodb: Use _global as host when none provided
James Callahan <james@chatid.com>
parents: 505
diff changeset
37 local host = module.host or "_global";
0e07810550c8 mod_storage_mongodb: Use _global as host when none provided
James Callahan <james@chatid.com>
parents: 505
diff changeset
38 local store = self.store;
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
39
507
46f578da4ff0 mod_storage_mongodb: assert the configuration options
James Callahan <james@chatid.com>
parents: 506
diff changeset
40 -- The database name can't have a period in it (hence it can't be a host/ip)
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
41 local namespace = params.dbname .. "." .. host;
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
42 local v = { _id = { store = store ; username = username } };
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
43
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
44 if next(data) ~= nil then -- set data
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
45 v.data = data;
1010
fd420237a5e4 mod_storage_mongodb: Use util.json to encode our data (handles non-string table keys, etc).
Waqas Hussain <waqas20@gmail.com>
parents: 813
diff changeset
46 return conn:insert ( namespace , json.encode(v) );
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
47 else -- delete data
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
48 return conn:remove ( namespace , v );
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
49 end;
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
50 end
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
51
1324
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
52 local roster_store = {};
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
53 roster_store.__index = roster_store;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
54
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
55 function roster_store:get(username)
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
56 local host = module.host or "_global";
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
57 local store = self.store;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
58
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
59 -- The database name can't have a period in it (hence it can't be a host/ip)
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
60 local namespace = params.dbname .. "." .. host;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
61 local v = { _id = { store = store ; username = username } };
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
62
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
63 local cursor , err = conn:query ( namespace , v );
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
64 if not cursor then return nil , err end;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
65
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
66 local r , err = cursor:next ( );
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
67 if not r then return nil , err end;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
68 local roster = {
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
69 [false] = {
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
70 version = r.version;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
71 };
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
72 pending = set.new( r.pending )._items;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
73 };
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
74 local items = r.items;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
75 for i = 1, #items do
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
76 local item = items[i];
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
77 roster[item.jid] = {
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
78 subscription = item.subscription;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
79 groups = set.new( item.groups )._items;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
80 ask = item.ask;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
81 name = item.name;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
82 }
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
83 end
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
84 return roster;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
85 end
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
86
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
87 function roster_store:set(username, data)
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
88 local host = module.host or "_global";
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
89 local store = self.store;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
90
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
91 -- The database name can't have a period in it (hence it can't be a host/ip)
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
92 local namespace = params.dbname .. "." .. host;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
93 local v = { _id = { store = store ; username = username } };
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
94
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
95 if data == nil or next(data) == nil then -- delete data
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
96 return conn:remove ( namespace , v );
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
97 end
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
98
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
99 v.version = data[false].version
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
100 if data.pending then
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
101 v.pending = array(it.keys(v.pending))
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
102 end
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
103
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
104 local items = {}
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
105 for jid, item in pairs(data) do
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
106 if jid and jid ~= "pending" then
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
107 table.insert(items, {
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
108 jid = jid;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
109 subscription = item.subscription;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
110 groups = array(it.keys( item.groups ));
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
111 name = item.name;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
112 ask = item.ask;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
113 });
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
114 end
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
115 end
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
116 v.items = items;
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
117
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
118 return conn:insert ( namespace , v );
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
119 end
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
120
813
2469f779b3f7 mod_storage_*: Update to use module:provides().
Waqas Hussain <waqas20@gmail.com>
parents: 509
diff changeset
121 local driver = {};
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
122
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
123 function driver:open(store, typ)
508
9831506dcfd6 mod_storage_mongodb: move database connecting to inside driver:open
James Callahan <james@chatid.com>
parents: 507
diff changeset
124 if not conn then
9831506dcfd6 mod_storage_mongodb: move database connecting to inside driver:open
James Callahan <james@chatid.com>
parents: 507
diff changeset
125 conn = assert ( mongo.Connection.New ( true ) );
9831506dcfd6 mod_storage_mongodb: move database connecting to inside driver:open
James Callahan <james@chatid.com>
parents: 507
diff changeset
126 assert ( conn:connect ( params.server ) );
509
bf2ad6d6c778 mod_storage_mongodb: (un)lock globals around require; only auth if we need to
James Callahan <james@chatid.com>
parents: 508
diff changeset
127 if params.username then
bf2ad6d6c778 mod_storage_mongodb: (un)lock globals around require; only auth if we need to
James Callahan <james@chatid.com>
parents: 508
diff changeset
128 assert ( conn:auth ( params ) );
bf2ad6d6c778 mod_storage_mongodb: (un)lock globals around require; only auth if we need to
James Callahan <james@chatid.com>
parents: 508
diff changeset
129 end
508
9831506dcfd6 mod_storage_mongodb: move database connecting to inside driver:open
James Callahan <james@chatid.com>
parents: 507
diff changeset
130 end
9831506dcfd6 mod_storage_mongodb: move database connecting to inside driver:open
James Callahan <james@chatid.com>
parents: 507
diff changeset
131
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
132 if not typ then -- default key-value store
1324
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
133 if store == "roster" then
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
134 return setmetatable({ store = store }, roster_store);
853a382c9bd6 mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents: 1010
diff changeset
135 end
504
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
136 return setmetatable({ store = store }, keyval_store);
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
137 end;
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
138 return nil, "unsupported-store";
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
139 end
0e9b43db7a2c mod_storage_mondodb: Add module
James Callahan <james@chatid.com>
parents:
diff changeset
140
813
2469f779b3f7 mod_storage_*: Update to use module:provides().
Waqas Hussain <waqas20@gmail.com>
parents: 509
diff changeset
141 module:provides("storage", driver);