Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MUC Light ODBC #1093

Merged
merged 11 commits into from
Dec 5, 2016
18 changes: 12 additions & 6 deletions apps/ejabberd/include/mod_muc_light.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
-define(NS_MUC_LIGHT_CREATE, <<"urn:xmpp:muclight:0#create">>).
-define(NS_MUC_LIGHT_DESTROY, <<"urn:xmpp:muclight:0#destroy">>).

-define(CODEC, mod_muc_light_codec_backend).
-define(BACKEND, mod_muc_light_db_backend).

-define(DEFAULT_EQUAL_OCCUPANTS, false).
-define(DEFAULT_LEGACY_MODE, false).
-define(DEFAULT_ROOMS_PER_USER, infinity).
Expand Down Expand Up @@ -40,12 +37,13 @@

-type rooms_per_user() :: infinity | non_neg_integer().

-type blocking_who() :: user | room.
-type blocking_what() :: user | room.
-type blocking_action() :: allow | deny.
-type blocking_who() :: ejabberd:simple_bare_jid().
-type blocking_item() :: {
What :: blocking_who(),
What :: blocking_what(),
Action :: blocking_action(),
Who :: ejabberd:simple_bare_jid()
Who :: blocking_who()
}.

-type disco_room_info() :: {RoomUS :: ejabberd:simple_bare_jid(),
Expand All @@ -56,12 +54,16 @@
id = <<>> :: binary()
}).

-type op_disco_info() :: #disco_info{}.

-record(disco_items, {
id = <<>> :: binary(),
rooms = [] :: [disco_room_info()],
rsm = none :: none | jlib:rsm_in() | jlib:rsm_out()
}).

-type op_disco_items() :: #disco_items{}.

-record(msg, {
id = <<>> :: binary(),
children = [] :: [jlib:xmlch()]
Expand Down Expand Up @@ -94,13 +96,17 @@
items = [] :: [blocking_item()]
}).

-type op_blocking() :: #blocking{}.

-record(create, {
id = <<>> :: binary(),
version = <<>> :: binary(),
raw_config = [] :: raw_config(),
aff_users = [] :: aff_users()
}).

-type op_create() :: #create{}.

-record(destroy, {
id = <<>> :: binary()
}).
Expand Down
39 changes: 39 additions & 0 deletions apps/ejabberd/priv/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,42 @@ CREATE TABLE offline_message(
packet blob NOT NULL
);
CREATE INDEX i_offline_message USING BTREE ON offline_message(server, username, id);

CREATE TABLE muc_light_rooms(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
luser VARCHAR(250) NOT NULL,
lserver VARCHAR(250) NOT NULL,
version VARCHAR(20) NOT NULL,
PRIMARY KEY (lserver, luser),
UNIQUE KEY k_id USING HASH (id)
);

CREATE INDEX i_muc_light_rooms USING HASH ON muc_light_rooms(id);

CREATE TABLE muc_light_occupants(
room_id BIGINT UNSIGNED NOT NULL REFERENCES muc_light_rooms(id),
luser VARCHAR(250) NOT NULL,
lserver VARCHAR(250) NOT NULL,
aff TINYINT UNSIGNED NOT NULL
);

CREATE INDEX i_muc_light_occupants_id USING HASH ON muc_light_occupants(room_id);
CREATE INDEX i_muc_light_occupants_us USING HASH ON muc_light_occupants(lserver, luser);

CREATE TABLE muc_light_config(
room_id BIGINT UNSIGNED NOT NULL REFERENCES muc_light_rooms(id),
opt VARCHAR(100) NOT NULL,
val VARCHAR(250) NOT NULL
);

CREATE INDEX i_muc_light_config USING HASH ON muc_light_config(room_id);

CREATE TABLE muc_light_blocking(
luser VARCHAR(250) NOT NULL,
lserver VARCHAR(250) NOT NULL,
what TINYINT UNSIGNED NOT NULL,
who VARCHAR(500) NOT NULL
);

CREATE INDEX i_muc_light_blocking USING HASH ON muc_light_blocking(luser, lserver);

35 changes: 35 additions & 0 deletions apps/ejabberd/priv/pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,38 @@ CREATE TABLE auth_token(
owner TEXT NOT NULL PRIMARY KEY,
seq_no BIGINT NOT NULL
);

CREATE TABLE muc_light_rooms(
id BIGSERIAL NOT NULL UNIQUE,
luser VARCHAR(250) NOT NULL,
lserver VARCHAR(250) NOT NULL,
version VARCHAR(20) NOT NULL,
PRIMARY KEY (lserver, luser)
);

CREATE TABLE muc_light_occupants(
room_id BIGINT NOT NULL REFERENCES muc_light_rooms(id),
luser VARCHAR(250) NOT NULL,
lserver VARCHAR(250) NOT NULL,
aff SMALLINT NOT NULL
);

CREATE INDEX i_muc_light_occupants_id ON muc_light_occupants (room_id);
CREATE INDEX i_muc_light_occupants_us ON muc_light_occupants (lserver, luser);

CREATE TABLE muc_light_config(
room_id BIGINT NOT NULL REFERENCES muc_light_rooms(id),
opt VARCHAR(100) NOT NULL,
val VARCHAR(250) NOT NULL
);

CREATE INDEX i_muc_light_config ON muc_light_config (room_id);

CREATE TABLE muc_light_blocking(
luser VARCHAR(250) NOT NULL,
lserver VARCHAR(250) NOT NULL,
what SMALLINT NOT NULL,
who VARCHAR(500) NOT NULL
);

CREATE INDEX i_muc_light_blocking ON muc_light_blocking (luser, lserver);
Loading