mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: fix pinnedDomains
This commit is contained in:
1 file changed
+5
-1
@@ -511,10 +511,14 @@ class HomeDomainCreateHandler extends Handler {
|
||||
if (doc) throw new DomainAlreadyExistsError(id);
|
||||
avatar ||= this.user.avatar || `gravatar:${this.user.mail}`;
|
||||
const domainId = await domain.add(id, this.user._id, name, bulletin);
|
||||
// When this domain is deleted but previously added to user's list we shouldn't push it again
|
||||
const push = !this.user.pinnedDomains?.includes(domainId);
|
||||
await Promise.all([
|
||||
domain.edit(domainId, { avatar }),
|
||||
domain.setUserRole(domainId, this.user._id, 'root'),
|
||||
user.setById(this.user._id, undefined, undefined, { pinnedDomains: domainId }),
|
||||
push
|
||||
? user.setById(this.user._id, undefined, undefined, { pinnedDomains: domainId })
|
||||
: Promise.resolve(),
|
||||
]);
|
||||
this.response.redirect = this.url('domain_dashboard', { domainId });
|
||||
this.response.body = { domainId };
|
||||
|
||||
Reference in new issue
Block a user