Can't accept a friend request after you ignored it

This commit is contained in:
Noah Petherbridge 2023-11-25 13:39:38 -08:00
parent 4846a88ab0
commit 7ef22db5e2
2 changed files with 16 additions and 3 deletions

View File

@ -36,6 +36,14 @@ func AddFriend(sourceUserID, targetUserID uint64) error {
targetUserID, sourceUserID,
).First(&rev).Error
// If we have previously Ignored the friend request, we can not Accept it but only Reject it.
if reverse == nil && rev.Ignored {
return errors.New(
"you have previously ignored a friend request from this person and can not accept it now - " +
"please go to your Friends page, Ignored tab, and remove the ignored friend request there and try again",
)
}
// If the reverse exists (requested us) but not the forward, this completes the friendship.
if reverse == nil && forward != nil {
// Approve the reverse.

View File

@ -115,7 +115,14 @@
</div>
</div>
</div>
{{if or $Root.IsRequests $Root.IsIgnored}}
{{if $Root.IsIgnored}}
<footer class="card-footer">
<button type="submit" name="verdict" value="reject" class="card-footer-item button is-danger is-outlined">
<span class="icon"><i class="fa fa-xmark"></i></span>
<span>Reject</span>
</button>
</footer>
{{else if $Root.IsRequests}}
<footer class="card-footer">
<button type="submit" name="verdict" value="approve" class="card-footer-item button is-success">
<span class="icon"><i class="fa fa-check"></i></span>
@ -125,12 +132,10 @@
<span class="icon"><i class="fa fa-xmark"></i></span>
<span>Reject</span>
</button>
{{if not $Root.IsIgnored}}
<button type="submit" name="verdict" value="ignore" class="card-footer-item button">
<span class="icon"><i class="fa fa-moon"></i></span>
<span>Ignore</span>
</button>
{{end}}
</footer>
{{else}}
<footer class="card-footer">