|
1 | 1 | /*
|
2 | 2 | Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
3 | 3 | Copyright (C) 2023 Spacebar and Spacebar Contributors
|
4 |
| - |
| 4 | +
|
5 | 5 | This program is free software: you can redistribute it and/or modify
|
6 | 6 | it under the terms of the GNU Affero General Public License as published
|
7 | 7 | by the Free Software Foundation, either version 3 of the License, or
|
8 | 8 | (at your option) any later version.
|
9 |
| - |
| 9 | +
|
10 | 10 | This program is distributed in the hope that it will be useful,
|
11 | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 | 13 | GNU Affero General Public License for more details.
|
14 |
| - |
| 14 | +
|
15 | 15 | You should have received a copy of the GNU Affero General Public License
|
16 | 16 | along with this program. If not, see <https://www.gnu.org/licenses/>.
|
17 | 17 | */
|
@@ -90,6 +90,24 @@ router.delete(
|
90 | 90 | } else if (channel.type === ChannelType.GROUP_DM) {
|
91 | 91 | await Channel.removeRecipientFromChannel(channel, req.user_id);
|
92 | 92 | } else {
|
| 93 | + if (channel.type == ChannelType.GUILD_CATEGORY) { |
| 94 | + const channels = await Channel.find({ |
| 95 | + where: { parent_id: channel_id }, |
| 96 | + }); |
| 97 | + for await (const c of channels) { |
| 98 | + c.parent_id = null; |
| 99 | + |
| 100 | + await Promise.all([ |
| 101 | + c.save(), |
| 102 | + emitEvent({ |
| 103 | + event: "CHANNEL_UPDATE", |
| 104 | + data: c, |
| 105 | + channel_id: c.id, |
| 106 | + } as ChannelUpdateEvent), |
| 107 | + ]); |
| 108 | + } |
| 109 | + } |
| 110 | + |
93 | 111 | await Promise.all([
|
94 | 112 | Channel.delete({ id: channel_id }),
|
95 | 113 | emitEvent({
|
|
0 commit comments