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

[markers] Implement all configuration for the smart_markers #3546

Merged
merged 3 commits into from
Mar 15, 2022

Conversation

NelsonVides
Copy link
Collaborator

@NelsonVides NelsonVides commented Feb 16, 2022

Implement the functionality as described in #3535

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Feb 16, 2022

Codecov Report

Merging #3546 (29480e0) into feature/smart_markers (ef8b27c) will increase coverage by 0.06%.
The diff coverage is 97.77%.

Impacted file tree graph

@@                    Coverage Diff                    @@
##           feature/smart_markers    #3546      +/-   ##
=========================================================
+ Coverage                  80.83%   80.89%   +0.06%     
=========================================================
  Files                        425      426       +1     
  Lines                      32273    32351      +78     
=========================================================
+ Hits                       26087    26171      +84     
+ Misses                      6186     6180       -6     
Impacted Files Coverage Δ
src/config/mongoose_config_spec.erl 99.21% <ø> (ø)
...rc/smart_markers/mod_smart_markers_rdbms_async.erl 92.59% <92.59%> (ø)
src/inbox/mod_inbox.erl 87.77% <100.00%> (ø)
src/offline/mod_offline_chatmarkers.erl 90.76% <100.00%> (ø)
src/smart_markers/mod_smart_markers.erl 95.55% <100.00%> (+4.81%) ⬆️
src/smart_markers/mod_smart_markers_backend.erl 100.00% <100.00%> (+5.00%) ⬆️
src/smart_markers/mod_smart_markers_rdbms.erl 94.54% <100.00%> (+2.44%) ⬆️
src/cassandra/mongoose_cassandra.erl 77.77% <0.00%> (-3.71%) ⬇️
src/mam/mod_mam_muc_rdbms_arch_async.erl 82.85% <0.00%> (-2.86%) ⬇️
src/cassandra/mongoose_cassandra_worker.erl 65.72% <0.00%> (-2.82%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef8b27c...29480e0. Read the comment docs.

Base automatically changed from markers/removals to master February 24, 2022 11:43
@NelsonVides NelsonVides changed the base branch from master to feature/smart_markers February 24, 2022 19:25
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@NelsonVides NelsonVides changed the title Implement all configuration for the smart_markers [markers] Implement all configuration for the smart_markers Mar 11, 2022
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Mar 11, 2022

small_tests_24 / small_tests / e0086bf
Reports root / small


small_tests_23 / small_tests / e0086bf
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / e0086bf
Reports root/ big
OK: 2800 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / e0086bf
Reports root/ big
OK: 2800 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / e0086bf
Reports root/ big
OK: 2783 / Failed: 0 / User-skipped: 150 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / e0086bf
Reports root/ big
OK: 2800 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / e0086bf
Reports root/ big
OK: 1504 / Failed: 0 / User-skipped: 399 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / e0086bf
Reports root/ big
OK: 1504 / Failed: 0 / User-skipped: 399 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / e0086bf
Reports root/ big
OK: 3174 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / e0086bf
Reports root/ big
OK: 3174 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / e0086bf
Reports root/ big
OK: 1846 / Failed: 0 / User-skipped: 366 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / e0086bf
Reports root/ big
OK: 1545 / Failed: 0 / User-skipped: 358 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / e0086bf
Reports root/ big
OK: 3169 / Failed: 0 / User-skipped: 147 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / e0086bf
Reports root/ big
OK: 3174 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / e0086bf
Reports root/ big
OK: 1692 / Failed: 0 / User-skipped: 365 / Auto-skipped: 0

Copy link
Contributor

@arcusfelis arcusfelis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, added some comments, otherwise - ok

Private :: boolean()) -> [mod_smart_markers:chat_marker()].
get_conv_chat_marker(HostType, From, To = #jid{lserver = TLS}, Thread, TS, Private) ->
% If To is a room, we'll want to check just the room
case mongoose_domain_api:get_subdomain_host_type(TLS) of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToLServer or ToServer (TLS and TLU are confusing)

type => decode_type(Type),
timestamp => decode_timestamp(MsgTS),
id => MsgId}
|| {LS, LU, ToJid, MsgThread, Type, MsgId, MsgTS} <- ChatMarkers].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tuple_to_map helper function would be useful here (also code dedup)

@@ -0,0 +1,118 @@
%%%----------------------------------------------------------------------------
%%% @copyright (C) 2020, Erlang Solutions Ltd.
%%% @doc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doc on one line

Msgs = [ escalus:wait_for_stanza(User) || User <- Users],
get_id(hd(Msgs), MsgId).

mark_msg(Users, RoomBinJid, Marker, StzId) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just StanzaId, there is zero benefits to use a short form

escalus:send(Writer, Msg),
[ escalus:wait_for_stanza(User) || User <- Users],
Msgs = [ escalus:wait_for_stanza(User) || User <- Users],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users ]

_ -> [{<<"after">>, After}]
end,
Iq = iq_fetch_marker(MarkedUserBJid ++ MaybeThread ++ MaybeAfter),
mongoose_helper:wait_until(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait until which waits for what exactly? (probably for not a crash, but still)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until it all returns fine, without crashing. There's a bunch of asserts inside that might fail but are eventually working, it just needs to fetch the iq again.

<<"type">>, <<"groupchat">>),
[ begin
escalus:send(User, ChatMarker),
{ok, MUser} = verify_marker_fetch(User, RoomBinJid),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MUser is a bad name for a list of elements.

Req = maps:from_list(SubEl#xmlel.attrs),
MaybePeer = jid:from_binary(maps:get(<<"peer">>, Req, undefined)),
MaybeAfter = parse_ts(maps:get(<<"after">>, Req, undefined)),
MaybeTread = maps:get(<<"thread">>, Req, undefined),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MaybeThread


-spec start_pool(mongooseim:host_type(), mongoose_async_pools:pool_opts()) -> term().
start_pool(HostType, Opts) ->
catch mongoose_async_pools:start_pool(HostType, smart_markers, Opts).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

report errors?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only happens during testing, where pools are turned on and off. For some reason out of the scope of this PR ejabberd_sup was still having the children somewhere there.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Mar 14, 2022

small_tests_24 / small_tests / 29480e0
Reports root / small


small_tests_23 / small_tests / 29480e0
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 29480e0
Reports root/ big
OK: 2800 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 29480e0
Reports root/ big
OK: 2800 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 29480e0
Reports root/ big
OK: 2783 / Failed: 0 / User-skipped: 150 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 29480e0
Reports root/ big
OK: 1504 / Failed: 0 / User-skipped: 399 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 29480e0
Reports root/ big
OK: 1545 / Failed: 0 / User-skipped: 358 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 29480e0
Reports root/ big
OK: 1504 / Failed: 0 / User-skipped: 399 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 29480e0
Reports root/ big
OK: 2800 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 29480e0
Reports root/ big
OK: 3174 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 29480e0
Reports root/ big
OK: 1846 / Failed: 0 / User-skipped: 366 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 29480e0
Reports root/ big
OK: 3174 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 29480e0
Reports root/ big
OK: 3169 / Failed: 0 / User-skipped: 147 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 29480e0
Reports root/ big
OK: 3174 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 29480e0
Reports root/ big
OK: 1692 / Failed: 0 / User-skipped: 365 / Auto-skipped: 0

@arcusfelis arcusfelis merged commit 02b6471 into feature/smart_markers Mar 15, 2022
@arcusfelis arcusfelis deleted the markers/iq branch March 15, 2022 11:03
@Premwoik Premwoik added this to the 5.1.0 milestone May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants