mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-22 20:10:40 +03:00
message&thread search user profile
This commit is contained in:
parent
1de709c632
commit
a471f19f04
5 changed files with 41 additions and 22 deletions
|
@ -4,9 +4,16 @@ const { limits } = require("../config.json");
|
||||||
|
|
||||||
const schema = new mongoose.Schema({
|
const schema = new mongoose.Schema({
|
||||||
id: { type: String, unique: true },
|
id: { type: String, unique: true },
|
||||||
author: Object,
|
authorID: {
|
||||||
|
type: String, get(v) { return v || this.author?.id }
|
||||||
|
},
|
||||||
|
author: {
|
||||||
|
type: Object, set(v) {
|
||||||
|
this.authorID = v.id;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
},
|
||||||
threadID: String,
|
threadID: String,
|
||||||
authorID: String,
|
|
||||||
content: { type: String, maxlength: limits.message },
|
content: { type: String, maxlength: limits.message },
|
||||||
oldContents: [String],
|
oldContents: [String],
|
||||||
time: { type: Date, default: Date.now },
|
time: { type: Date, default: Date.now },
|
||||||
|
|
|
@ -7,8 +7,15 @@ const schema = new mongoose.Schema({
|
||||||
id: { type: String, unique: true },
|
id: { type: String, unique: true },
|
||||||
|
|
||||||
categoryID: String,
|
categoryID: String,
|
||||||
authorID: String,
|
authorID: {
|
||||||
author: Object,
|
type: String, get(v) { return v || this.author?.id }
|
||||||
|
},
|
||||||
|
author: {
|
||||||
|
type: Object, set(v) {
|
||||||
|
this.authorID = v.id;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
title: { type: String, maxlength: limits.title },
|
title: { type: String, maxlength: limits.title },
|
||||||
oldTitles: [String],
|
oldTitles: [String],
|
||||||
|
|
|
@ -4,10 +4,15 @@ const UserCache = [];
|
||||||
module.exports.getAuthor = async function () {
|
module.exports.getAuthor = async function () {
|
||||||
const id = this.authorID || this.author?.id;
|
const id = this.authorID || this.author?.id;
|
||||||
let user = UserCache.find(user => user?.id == id)
|
let user = UserCache.find(user => user?.id == id)
|
||||||
if (!user) {
|
if (!user)
|
||||||
user = await UserModel.findOne({ id })
|
UserCache.push(user = await UserModel.findOne({ id }))
|
||||||
UserCache.push(user)
|
|
||||||
|
if (!this.get('authorID', null, { getters: false })) {
|
||||||
|
this.authorID = user.id;
|
||||||
|
await this.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.author = user;
|
this.author = user;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
|
@ -22,18 +22,18 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.box-title{
|
.box-title {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
color: var(--anti);
|
||||||
}
|
}
|
||||||
|
|
||||||
.box-value {
|
.box-value {
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
background-color: var(--main);
|
background-color: var(--main);
|
||||||
color: white;
|
color: white;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -148,11 +148,11 @@ color: var(--anti);
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h2 class="box-title">Message:</h2>
|
<a href="/search/messages?authorID=<%= member.id %>" class="box-title">Message:</a>
|
||||||
<h2 class="box-value"><%= counts.message %></h2>
|
<a class="box-value"><%= counts.message %></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h2 class="box-title">Thread:</h2>
|
<a href="/search/threads?authorID=<%= member.id %>" class="box-title">Thread:</a>
|
||||||
<h2 class="box-value"><%= counts.thread %></h2>
|
<h2 class="box-value"><%= counts.thread %></h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue