25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Merge pull request #3127 from area-42/allow_emojis_with_mssql

allow storage of emojis in archive on mssql
This commit is contained in:
Mickaël Rémond 2020-02-20 16:28:24 +01:00 committed by GitHub
commit 3947e64524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 31 deletions

View File

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

View File

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