Fix: draft-published event is not visible
The draft-published event was not visible to users other than the owner and reviewers, because when the event was fired it was being given patchset and change objects that were still in draft state. Change it to take the updated patchset and change objects. Bug: Issue 1621 Change-Id: I0dbdc5ff7804450d8b5c8a424a8cb1b0059b4029
This commit is contained in:

committed by
Edwin Kempin

parent
78c2bfd10c
commit
f7b3e99ecc
@@ -74,47 +74,29 @@ public class PublishDraft implements Callable<ReviewResult> {
|
||||
result.addError(new ReviewResult.Error(
|
||||
ReviewResult.Error.Type.PUBLISH_NOT_PERMITTED));
|
||||
} else {
|
||||
boolean published = false;
|
||||
final PatchSet updatedPatch = db.patchSets().atomicUpdate(patchSetId,
|
||||
new AtomicUpdate<PatchSet>() {
|
||||
@Override
|
||||
public PatchSet update(PatchSet patchset) {
|
||||
if (patchset.isDraft()) {
|
||||
patchset.setDraft(false);
|
||||
return patchset;
|
||||
}
|
||||
return null;
|
||||
patchset.setDraft(false);
|
||||
return patchset;
|
||||
}
|
||||
});
|
||||
|
||||
if ((updatedPatch != null) && (!updatedPatch.isDraft())) {
|
||||
published = true;
|
||||
}
|
||||
|
||||
final Change change = db.changes().get(changeId);
|
||||
if (change.getStatus() == Change.Status.DRAFT) {
|
||||
final Change updatedChange = db.changes().atomicUpdate(changeId,
|
||||
new AtomicUpdate<Change>() {
|
||||
@Override
|
||||
public Change update(Change change) {
|
||||
if (change.getStatus() == Change.Status.DRAFT) {
|
||||
change.setStatus(Change.Status.NEW);
|
||||
ChangeUtil.updated(change);
|
||||
return change;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
final Change updatedChange = db.changes().atomicUpdate(changeId,
|
||||
new AtomicUpdate<Change>() {
|
||||
@Override
|
||||
public Change update(Change change) {
|
||||
if (change.getStatus() == Change.Status.DRAFT) {
|
||||
change.setStatus(Change.Status.NEW);
|
||||
ChangeUtil.updated(change);
|
||||
}
|
||||
});
|
||||
|
||||
if ((updatedChange != null) &&
|
||||
(updatedChange.getStatus() == Change.Status.NEW)) {
|
||||
published = true;
|
||||
return change;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (published) {
|
||||
hooks.doDraftPublishedHook(change, patch, db);
|
||||
if (!updatedPatch.isDraft() || updatedChange.getStatus() == Change.Status.NEW) {
|
||||
hooks.doDraftPublishedHook(updatedChange, updatedPatch, db);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user