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

[FIX] Email notifications settings not being honored on new DMs #23574

Merged
merged 14 commits into from
Dec 20, 2021
4 changes: 3 additions & 1 deletion app/lib/server/functions/createDirectRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { callbacks } from '../../../callbacks/server';
import { Rooms, Subscriptions } from '../../../models/server';
import { settings } from '../../../settings/server';
import { getDefaultSubscriptionPref } from '../../../utils/server';
import { Users } from '../../../models';
ostjen marked this conversation as resolved.
Show resolved Hide resolved

const generateSubscription = (fname, name, user, extra) => ({
alert: false,
Expand Down Expand Up @@ -90,13 +91,14 @@ export const createDirectRoom = function(members, roomExtraData = {}, options =
} else {
members.forEach((member) => {
const otherMembers = sortedMembers.filter(({ _id }) => _id !== member._id);
const memberWithPreferences = Users.findOneByUsername(member.username, { fields: { username: 1, 'settings.preferences': 1 } });
ostjen marked this conversation as resolved.
Show resolved Hide resolved

Subscriptions.upsert({ rid, 'u._id': member._id }, {
...options.creator === member._id && { $set: { open: true } },
$setOnInsert: generateSubscription(
getFname(otherMembers),
getName(otherMembers),
member,
memberWithPreferences,
{
...options.subscriptionExtra,
...options.creator !== member._id && { open: members.length > 2 },
Expand Down