mirror of
https://github.com/discourse/discourse.git
synced 2026-08-12 05:37:26 +08:00
The backend only checks for `guardian.ensure_can_edit!(post)` and not admin. However the initialiser was under admin folder, meaning the click would only work for admins, even though they could have made the http request directly.
30 lines
881 B
JavaScript
Vendored
30 lines
881 B
JavaScript
Vendored
import { ajax } from "discourse/lib/ajax";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
import { makeArray } from "discourse/lib/helpers";
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
|
|
function _initializeGLobalUserNotices(api) {
|
|
const currentUser = api.getCurrentUser();
|
|
|
|
makeArray(currentUser?.global_notices).forEach((userGlobalNotice) => {
|
|
api.addGlobalNotice("", userGlobalNotice.identifier, {
|
|
html: userGlobalNotice.notice,
|
|
level: userGlobalNotice.level,
|
|
dismissable: true,
|
|
dismissDuration: moment.duration(1, "week"),
|
|
onDismiss() {
|
|
ajax(`/user-global-notices/${userGlobalNotice.id}.json`, {
|
|
type: "DELETE",
|
|
}).catch(popupAjaxError);
|
|
},
|
|
});
|
|
});
|
|
}
|
|
|
|
export default {
|
|
name: "discourse-automation",
|
|
|
|
initialize() {
|
|
withPluginApi(_initializeGLobalUserNotices);
|
|
},
|
|
};
|