|
|
@@ -54,6 +54,7 @@ export class MomentsService {
|
|
|
|
|
|
const query = await this.momentsRepository.createQueryBuilder('moments')
|
|
|
.where('moments.isDel = false')
|
|
|
+ .andWhere('moments.isPush = true')
|
|
|
|
|
|
if (req.search) {
|
|
|
const searchOptions = req.search as FindManyOptions<Moments>;
|
|
|
@@ -140,14 +141,15 @@ export class MomentsService {
|
|
|
}
|
|
|
|
|
|
public async automaticallySendMoments() {
|
|
|
- const message = "我需要你以类似于朋友圈的方式发一条此时此刻的动态,尽量符合角色性格."
|
|
|
+ //const message = "我需要你以类似于朋友圈的方式发一条此时此刻的动态,尽量符合角色性格."
|
|
|
const chatRoleList = await this.chatRoleRepository.createQueryBuilder().getMany()
|
|
|
|
|
|
chatRoleList.forEach(async role => {
|
|
|
- const text = await this.chatService.sendMessage(role.condition, message)
|
|
|
+ const text = await this.chatService.sendMessage(null, role.condition)
|
|
|
const momentsDto = new MomentsDto
|
|
|
momentsDto.content = text
|
|
|
momentsDto.userId = role.id
|
|
|
+ momentsDto.isPush = false
|
|
|
await this.momentsRepository.save(momentsDto)
|
|
|
})
|
|
|
}
|
|
|
@@ -155,7 +157,7 @@ export class MomentsService {
|
|
|
|
|
|
public async delay() {
|
|
|
const momentsList = await this.momentsRepository.createQueryBuilder('moments')
|
|
|
- .where('moments.isDel = true')
|
|
|
+ .where('moments.isPush = false')
|
|
|
.getMany()
|
|
|
|
|
|
momentsList.forEach(moments => {
|
|
|
@@ -163,7 +165,8 @@ export class MomentsService {
|
|
|
const minutes = Math.floor(Math.random() * 60)
|
|
|
console.log(moments.userId + '的动态将在' + hours + '小时' + minutes + '分后发布')
|
|
|
setTimeout(async () => {
|
|
|
- moments.isDel = false
|
|
|
+ moments.isPush = true
|
|
|
+ moments.createdAt = new Date()
|
|
|
await this.momentsRepository.save(moments)
|
|
|
const chatRole = await this.chatRoleRepository.findOneBy({ id: moments.userId })
|
|
|
chatRole.dynamicNumber += 1
|