Skip to content

Commit

Permalink
perf: associate ghost user with posts on user deletion. (#3293)
Browse files Browse the repository at this point in the history
#### What type of PR is this?

/kind bug

#### What this PR does / why we need it:

文章发布用户被删除后,设置这篇文章的发布人为Ghost

#### Which issue(s) this PR fixes:

Fixes #3265

```release-note
NONE
```
  • Loading branch information
JackyLiang522 authored Feb 15, 2023
1 parent 26f29b2 commit e485ace
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main/java/run/halo/app/content/Contributor.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ public class Contributor {
private String displayName;
private String avatar;
private String name;

public static Contributor getGhost() {
Contributor contributor = new Contributor();
contributor.setName("ghost");
contributor.setDisplayName("已删除用户");
return contributor;
}
}
3 changes: 2 additions & 1 deletion src/main/java/run/halo/app/content/impl/PostServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ private Flux<Contributor> listContributors(List<String> usernames) {
contributor.setDisplayName(user.getSpec().getDisplayName());
contributor.setAvatar(user.getSpec().getAvatar());
return contributor;
});
})
.defaultIfEmpty(Contributor.getGhost());
}

@Override
Expand Down

0 comments on commit e485ace

Please sign in to comment.