Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

DEV-8795 Programatically fix the #general channel issue #32

Merged
merged 1 commit into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions app/lib/server/functions/addUserToDefaultChannels.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,2 @@
import { Rooms, Subscriptions, Messages } from '../../../models';
import { callbacks } from '../../../callbacks';

export const addUserToDefaultChannels = function(user, silenced) {
callbacks.run('beforeJoinDefaultChannels', user);
const defaultRooms = Rooms.findByDefaultAndTypes(true, ['c', 'p'], { fields: { usernames: 0 } }).fetch();
defaultRooms.forEach((room) => {
if (!Subscriptions.findOneByRoomIdAndUserId(room._id, user._id)) {
// Add a subscription to this user
Subscriptions.createWithRoomAndUser(room, user, {
ts: new Date(),
open: true,
alert: true,
unread: 1,
userMentions: 1,
groupMentions: 0,
...room.favorite && { f: true },
});

// Insert user joined message
if (!silenced) {
Messages.createUserJoinWithRoomIdAndUser(room._id, user);
}
}
});
export const addUserToDefaultChannels = function() {
};
1 change: 0 additions & 1 deletion app/lib/server/methods/setUsername.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Meteor.methods({
}

if (!user.username) {
Meteor.runAsUser(user._id, () => Meteor.call('joinDefaultChannels', joinDefaultChannelsSilenced));
Meteor.defer(function() {
return callbacks.run('afterCreateUser', Users.findOneById(user._id));
});
Expand Down
6 changes: 0 additions & 6 deletions app/ui-flextab/client/tabs/userEdit.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,6 @@
</div>

{{#unless user}}
<div class="input-line">
<label for="joinDefaultChannels">
<input type="checkbox" id="joinDefaultChannels" value="1" checked="true">
{{_ "Join_default_channels"}}
</label>
</div>
<div class="input-line">
<label for="sendWelcomeEmail">
<input type="checkbox" id="sendWelcomeEmail" value="1" checked="true">
Expand Down
1 change: 0 additions & 1 deletion app/ui-flextab/client/tabs/userEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ Template.userEdit.onCreated(function() {
userData.password = s.trim(this.$('#password').val());
userData.setRandomPassword = this.$('#setRandomPassword:checked').length > 0;
userData.requirePasswordChange = this.$('#changePassword:checked').length > 0;
userData.joinDefaultChannels = this.$('#joinDefaultChannels:checked').length > 0;
userData.sendWelcomeEmail = this.$('#sendWelcomeEmail:checked').length > 0;
const roleSelect = this.$('.remove-role').toArray();

Expand Down
6 changes: 0 additions & 6 deletions server/startup/initialData.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import { checkUsernameAvailability, addUserToDefaultChannels } from '../../app/l

Meteor.startup(function() {
Meteor.defer(() => {
if (!Rooms.findOneById('GENERAL')) {
Rooms.createWithIdTypeAndName('GENERAL', 'c', 'general', {
default: true,
});
}

if (!Users.findOneById('genius')) {
Users.create({
_id: 'genius',
Expand Down