25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

allow storage of emojis in archive on mssql

This commit is contained in:
Christoph Scholz 2019-12-27 13:05:18 +01:00
parent bbe404abcc
commit 00ccb119ea
2 changed files with 66 additions and 31 deletions

View File

@ -26,8 +26,8 @@ CREATE TABLE [dbo].[archive] (
[timestamp] [bigint] NOT NULL, [timestamp] [bigint] NOT NULL,
[peer] [varchar] (250) NOT NULL, [peer] [varchar] (250) NOT NULL,
[bare_peer] [varchar] (250) NOT NULL, [bare_peer] [varchar] (250) NOT NULL,
[xml] [text] NOT NULL, [xml] [ntext] NOT NULL,
[txt] [text] NULL, [txt] [ntext] NULL,
[id] [bigint] IDENTITY(1,1) NOT NULL, [id] [bigint] IDENTITY(1,1) NOT NULL,
[kind] [varchar] (10) NULL, [kind] [varchar] (10) NULL,
[nick] [varchar] (250) NULL, [nick] [varchar] (250) NULL,

View File

@ -105,6 +105,7 @@ store(Pkt, LServer, {LUser, LHost}, Type, Peer, Nick, _Dir, TS) ->
jid:tolower(Peer)), jid:tolower(Peer)),
Body = fxml:get_subtag_cdata(Pkt, <<"body">>), Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
SType = misc:atom_to_binary(Type), SType = misc:atom_to_binary(Type),
SqlType = ejabberd_option:sql_type(LHost),
XML = case mod_mam_opt:compress_xml(LServer) of XML = case mod_mam_opt:compress_xml(LServer) of
true -> true ->
J1 = case Type of J1 = case Type of
@ -115,24 +116,44 @@ store(Pkt, LServer, {LUser, LHost}, Type, Peer, Nick, _Dir, TS) ->
_ -> _ ->
fxml:element_to_binary(Pkt) fxml:element_to_binary(Pkt)
end, end,
case ejabberd_sql:sql_query( case SqlType of
LServer, mssql -> case ejabberd_sql:sql_query(
?SQL_INSERT( LServer,
"archive", ?SQL_INSERT(
["username=%(SUser)s", "archive",
"server_host=%(LServer)s", ["username=%(SUser)s",
"timestamp=%(TS)d", "server_host=%(LServer)s",
"peer=%(LPeer)s", "timestamp=%(TS)d",
"bare_peer=%(BarePeer)s", "peer=%(LPeer)s",
"xml=%(XML)s", "bare_peer=%(BarePeer)s",
"txt=%(Body)s", "xml=N%(XML)s",
"kind=%(SType)s", "txt=N%(Body)s",
"nick=%(Nick)s"])) of "kind=%(SType)s",
{updated, _} -> "nick=%(Nick)s"])) of
ok; {updated, _} ->
Err -> ok;
Err Err ->
end. Err
end;
_ -> case ejabberd_sql:sql_query(
LServer,
?SQL_INSERT(
"archive",
["username=%(SUser)s",
"server_host=%(LServer)s",
"timestamp=%(TS)d",
"peer=%(LPeer)s",
"bare_peer=%(BarePeer)s",
"xml=%(XML)s",
"txt=%(Body)s",
"kind=%(SType)s",
"nick=%(Nick)s"])) of
{updated, _} ->
ok;
Err ->
Err
end
end.
write_prefs(LUser, _LServer, #archive_prefs{default = Default, write_prefs(LUser, _LServer, #archive_prefs{default = Default,
never = Never, never = Never,
@ -304,17 +325,31 @@ export(_Server) ->
XML = fxml:element_to_binary(Pkt), XML = fxml:element_to_binary(Pkt),
Body = fxml:get_subtag_cdata(Pkt, <<"body">>), Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
SType = misc:atom_to_binary(Type), SType = misc:atom_to_binary(Type),
[?SQL_INSERT( SqlType = ejabberd_option:sql_type(Host),
"archive", case SqlType of
["username=%(SUser)s", mssql -> [?SQL_INSERT(
"server_host=%(LServer)s", "archive",
"timestamp=%(TStmp)d", ["username=%(SUser)s",
"peer=%(LPeer)s", "server_host=%(LServer)s",
"bare_peer=%(BarePeer)s", "timestamp=%(TStmp)d",
"xml=%(XML)s", "peer=%(LPeer)s",
"txt=%(Body)s", "bare_peer=%(BarePeer)s",
"kind=%(SType)s", "xml=N%(XML)s",
"nick=%(Nick)s"])]; "txt=N%(Body)s",
"kind=%(SType)s",
"nick=%(Nick)s"])];
_ -> [?SQL_INSERT(
"archive",
["username=%(SUser)s",
"server_host=%(LServer)s",
"timestamp=%(TStmp)d",
"peer=%(LPeer)s",
"bare_peer=%(BarePeer)s",
"xml=%(XML)s",
"txt=%(Body)s",
"kind=%(SType)s",
"nick=%(Nick)s"])]
end;
(_Host, _R) -> (_Host, _R) ->
[] []
end}]. end}].