2019-04-18 14:10:56 -04:00
|
|
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad_component";
|
2019-04-06 21:14:27 -04:00
|
|
|
import {
|
|
|
|
default as computed,
|
|
|
|
observes
|
|
|
|
} from "ember-addons/ember-computed-decorators";
|
|
|
|
|
2019-04-12 08:08:25 -04:00
|
|
|
const currentUser = Discourse.User.current(),
|
2019-04-06 21:14:27 -04:00
|
|
|
serve_id = Discourse.SiteSettings.carbonads_serve_id,
|
|
|
|
placement = Discourse.SiteSettings.carbonads_placement;
|
|
|
|
|
2019-04-18 14:10:56 -04:00
|
|
|
export default AdComponent.extend({
|
|
|
|
init() {
|
2019-04-06 21:14:27 -04:00
|
|
|
this.set("serve_id", serve_id);
|
|
|
|
this.set("placement", placement);
|
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
|
2019-04-12 08:10:55 -04:00
|
|
|
@computed("serve_id", "placement")
|
2019-04-18 14:10:56 -04:00
|
|
|
url(serveId, placement) {
|
|
|
|
return `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`.htmlSafe();
|
2019-04-12 08:10:55 -04:00
|
|
|
},
|
|
|
|
|
2019-04-18 14:10:56 -04:00
|
|
|
@computed("currentUser.trust_level")
|
|
|
|
showToTrustLevel(trustLevel) {
|
2019-04-06 21:14:27 -04:00
|
|
|
return !(
|
2019-04-18 14:10:56 -04:00
|
|
|
trustLevel &&
|
|
|
|
trustLevel > Discourse.SiteSettings.carbonads_through_trust_level
|
2019-04-06 21:14:27 -04:00
|
|
|
);
|
2019-04-12 08:10:55 -04:00
|
|
|
},
|
2019-04-06 21:14:27 -04:00
|
|
|
|
2019-04-18 14:10:56 -04:00
|
|
|
@computed("showToTrustLevel", "showToGroups")
|
|
|
|
showAd(showToTrustLevel, showToGroups) {
|
|
|
|
return placement && serve_id && showToTrustLevel && showToGroups;
|
2019-04-06 21:14:27 -04:00
|
|
|
}
|
|
|
|
});
|