feat: make amount of items sent on email configurable via occ#2673
Conversation
|
Please note that psalm CI error is unrelated. |
|
Can you please add some tests? |
e206438 to
27d5fe4
Compare
27d5fe4 to
c5a7934
Compare
|
Did you test the performance when having that many items? |
I tested with the following env (nextcloud/nextcloud-docker-dev):
for i in $(seq 1 30); do
OC_PASS=admin docker exec -e OC_PASS=admin master-nextcloud-1 occ user:add --password-from-env --email user$i@mail.com user$i
done
docker exec master-nextcloud-1 occ config:app:set activity mail_max_items --value=1000
-- 1 user
SET @now = UNIX_TIMESTAMP();
INSERT INTO `oc_activity_mq` (`amq_timestamp`, `amq_latest_send`, `amq_type`, `amq_affecteduser`, `amq_appid`, `amq_subject`, `amq_subjectparams`, `object_type`, `object_id`)
SELECT @now, @now, 'shared', u.user, 'files_sharing', 'shared_with_by', '[{"462":"\/mock.json"},"admin"]', 'files', 462
FROM (SELECT 1 FROM information_schema.columns LIMIT 1005) t
CROSS JOIN (SELECT 'user1' AS user) u;
-- 10 users
SET @now = UNIX_TIMESTAMP();
INSERT INTO `oc_activity_mq` (`amq_timestamp`, `amq_latest_send`, `amq_type`, `amq_affecteduser`, `amq_appid`, `amq_subject`, `amq_subjectparams`, `object_type`, `object_id`)
SELECT @now, @now, 'shared', u.user, 'files_sharing', 'shared_with_by', '[{"462":"\/mock.json"},"admin"]', 'files', 462
FROM (SELECT 1 FROM information_schema.columns LIMIT 1005) t
CROSS JOIN (SELECT 'user1' AS user UNION ALL SELECT 'user2' UNION ALL SELECT 'user3' UNION ALL SELECT 'user4' UNION ALL SELECT 'user5' UNION ALL SELECT 'user6' UNION ALL SELECT 'user7' UNION ALL SELECT 'user8' UNION ALL SELECT 'user9' UNION ALL SELECT 'user10') u;
-- 20 users
SET @now = UNIX_TIMESTAMP();
INSERT INTO `oc_activity_mq` (`amq_timestamp`, `amq_latest_send`, `amq_type`, `amq_affecteduser`, `amq_appid`, `amq_subject`, `amq_subjectparams`, `object_type`, `object_id`)
SELECT @now, @now, 'shared', u.user, 'files_sharing', 'shared_with_by', '[{"462":"\/mock.json"},"admin"]', 'files', 462
FROM (SELECT 1 FROM information_schema.columns LIMIT 1005) t
CROSS JOIN (SELECT 'user1' AS user UNION ALL SELECT 'user2' UNION ALL SELECT 'user3' UNION ALL SELECT 'user4' UNION ALL SELECT 'user5' UNION ALL SELECT 'user6' UNION ALL SELECT 'user7' UNION ALL SELECT 'user8' UNION ALL SELECT 'user9' UNION ALL SELECT 'user10' UNION ALL SELECT 'user11' UNION ALL SELECT 'user12' UNION ALL SELECT 'user13' UNION ALL SELECT 'user14' UNION ALL SELECT 'user15' UNION ALL SELECT 'user16' UNION ALL SELECT 'user17' UNION ALL SELECT 'user18' UNION ALL SELECT 'user19' UNION ALL SELECT 'user20') u;
-- 30 users
SET @now = UNIX_TIMESTAMP();
INSERT INTO `oc_activity_mq` (`amq_timestamp`, `amq_latest_send`, `amq_type`, `amq_affecteduser`, `amq_appid`, `amq_subject`, `amq_subjectparams`, `object_type`, `object_id`)
SELECT @now, @now, 'shared', u.user, 'files_sharing', 'shared_with_by', '[{"462":"\/mock.json"},"admin"]', 'files', 462
FROM (SELECT 1 FROM information_schema.columns LIMIT 1005) t
CROSS JOIN (SELECT 'user1' AS user UNION ALL SELECT 'user2' UNION ALL SELECT 'user3' UNION ALL SELECT 'user4' UNION ALL SELECT 'user5' UNION ALL SELECT 'user6' UNION ALL SELECT 'user7' UNION ALL SELECT 'user8' UNION ALL SELECT 'user9' UNION ALL SELECT 'user10' UNION ALL SELECT 'user11' UNION ALL SELECT 'user12' UNION ALL SELECT 'user13' UNION ALL SELECT 'user14' UNION ALL SELECT 'user15' UNION ALL SELECT 'user16' UNION ALL SELECT 'user17' UNION ALL SELECT 'user18' UNION ALL SELECT 'user19' UNION ALL SELECT 'user20' UNION ALL SELECT 'user21' UNION ALL SELECT 'user22' UNION ALL SELECT 'user23' UNION ALL SELECT 'user24' UNION ALL SELECT 'user25' UNION ALL SELECT 'user26' UNION ALL SELECT 'user27' UNION ALL SELECT 'user28' UNION ALL SELECT 'user29' UNION ALL SELECT 'user30') u;
docker exec master-nextcloud-1 occ background-job:list | grep EmailNotification
time docker exec master-nextcloud-1 occ background-job:execute <job-id>
@miaulalala not sure if this is the kind of testing you had in mind. If you think a different approach would be more appropriate, feel free to let me know. |
Nice, that's exactly what I had in mind. |
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
c5a7934 to
1838024
Compare
|
/backport to stable34 |
|
/backport to stable33 |
|
@cristianscheid triggered backports down to 33 |






Summary
Context
OCA\Activity\BackgroundJob\EmailNotificationbackground jobMailQueueHandler::sendEmails()MailQueueHandler::ENTRY_LIMITdefines how many activities are fully shown in the email body, anything beyond that is truncated, as shown below:Changes introduced by this PR
MailQueueHandler::MAIL_MAX_ITEMS_CAPas a safeguard against excessively large valuesChecklist
3. to review, feature component)stable32)AI (if applicable)