Repeated punishment withdraws old punishments

main
Inga 🏳‍🌈 14 years ago
parent b22687e555
commit 2e2334a38d
  1. 2
      Builder/IISMainHandler/build.txt
  2. 24
      Common/dataobjects/Post.cs

@ -335,20 +335,37 @@ namespace FLocal.Common.dataobjects {
}
}
private readonly object Punish_Locker = new object();
public void Punish(Account account, PunishmentType type, string comment) {
if(!Moderator.isModerator(account, this.thread.board)) throw new FLocalException(account.id + " is not a moderator in board " + this.thread.board.id);
if(account.user.id == this.poster.id) throw new FLocalException("You cannot punish your own posts");
ChangeSetUtil.ApplyChanges(
lock(this.Punish_Locker) {
List<AbstractChange> changes = (
from punishment in this.punishments
select (AbstractChange)new UpdateChange(
Punishment.TableSpec.instance,
new Dictionary<string,AbstractFieldValue> {
{ Punishment.TableSpec.FIELD_ISWITHDRAWED, new ScalarFieldValue("1") },
},
punishment.id
)
).ToList();
changes.Add(
new UpdateChange(
TableSpec.instance,
new Dictionary<string,AbstractFieldValue> {
{ TableSpec.FIELD_TOTALPUNISHMENTS, new IncrementFieldValue() },
},
this.id
),
)
);
changes.Add(
new InsertChange(
Punishment.TableSpec.instance,
new Dictionary<string,AbstractFieldValue> {
@ -364,6 +381,8 @@ namespace FLocal.Common.dataobjects {
)
);
ChangeSetUtil.ApplyChanges(changes.ToArray());
this.punishments_Reset();
Account posterAccount = null;
@ -382,6 +401,7 @@ namespace FLocal.Common.dataobjects {
newMessage.conversation.markAsRead(account, newMessage, newMessage);
}
}
}
}
}

Loading…
Cancel
Save