mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-12-22 15:49:08 +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({
|
||||
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,
|
||||
authorID: String,
|
||||
content: { type: String, maxlength: limits.message },
|
||||
oldContents: [String],
|
||||
time: { type: Date, default: Date.now },
|
||||
|
|
|
@ -7,8 +7,15 @@ const schema = new mongoose.Schema({
|
|||
id: { type: String, unique: true },
|
||||
|
||||
categoryID: String,
|
||||
authorID: String,
|
||||
author: Object,
|
||||
authorID: {
|
||||
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 },
|
||||
oldTitles: [String],
|
||||
|
|
|
@ -4,10 +4,15 @@ const UserCache = [];
|
|||
module.exports.getAuthor = async function () {
|
||||
const id = this.authorID || this.author?.id;
|
||||
let user = UserCache.find(user => user?.id == id)
|
||||
if (!user) {
|
||||
user = await UserModel.findOne({ id })
|
||||
UserCache.push(user)
|
||||
if (!user)
|
||||
UserCache.push(user = await UserModel.findOne({ id }))
|
||||
|
||||
if (!this.get('authorID', null, { getters: false })) {
|
||||
this.authorID = user.id;
|
||||
await this.save();
|
||||
}
|
||||
|
||||
this.author = user;
|
||||
|
||||
return this;
|
||||
}
|
|
@ -22,18 +22,18 @@
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.box-title{
|
||||
.box-title {
|
||||
font-weight: 400;
|
||||
color: var(--anti);
|
||||
}
|
||||
|
||||
.box-value {
|
||||
font-weight: 300;
|
||||
background-color: var(--main);
|
||||
color: white;
|
||||
font-size: 14px;
|
||||
padding: 4px;
|
||||
border-radius: 5px;
|
||||
min-width: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
font-weight: 300;
|
||||
background-color: var(--main);
|
||||
color: white;
|
||||
font-size: 14px;
|
||||
padding: 4px;
|
||||
border-radius: 5px;
|
||||
min-width: 50px;
|
||||
text-align: center;
|
||||
}
|
|
@ -148,11 +148,11 @@ color: var(--anti);
|
|||
</div>
|
||||
<% } %>
|
||||
<div class="box">
|
||||
<h2 class="box-title">Message:</h2>
|
||||
<h2 class="box-value"><%= counts.message %></h2>
|
||||
<a href="/search/messages?authorID=<%= member.id %>" class="box-title">Message:</a>
|
||||
<a class="box-value"><%= counts.message %></a>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue