Use separate slack channel for inventory messages
This commit is contained in:
parent
a4b92f8008
commit
24bc46e098
@ -23,6 +23,12 @@ spec:
|
||||
env:
|
||||
- name: OIDC_USERS_NAMESPACE
|
||||
value: "oidc-gateway"
|
||||
- name: SLACK_DOORLOG_CALLBACK
|
||||
value: "changeme"
|
||||
- name: SLACK_INVENTORY_CALLBACK
|
||||
value: "changeme"
|
||||
- name: SLACK_VERIFICATION_TOKEN
|
||||
value: "changeme"
|
||||
- name: INVENTORY_API_KEY
|
||||
value: "sptWL6XFxl4b8"
|
||||
- name: PYTHONUNBUFFERED
|
||||
|
@ -93,11 +93,15 @@ def flatten(d, parent_key='', sep='.'):
|
||||
items.append((new_key, v))
|
||||
return dict(items)
|
||||
|
||||
def spam(msg):
|
||||
def spam(msg, channel="doorboy"):
|
||||
if devenv:
|
||||
print(msg)
|
||||
print(f"{channel}: {msg}")
|
||||
else:
|
||||
url = const.SLACK_DOORLOG_CALLBACK
|
||||
urls = {
|
||||
"doorboy": const.SLACK_DOORLOG_CALLBACK,
|
||||
"inventory": const.SLACK_INVENTORY_CALLBACK
|
||||
}
|
||||
url = urls.get(channel, const.SLACK_DOORLOG_CALLBACK)
|
||||
requests.post(url, json={"text": msg })
|
||||
|
||||
def build_query(base_query, fields=[], sort_fields={}):
|
||||
|
@ -20,4 +20,5 @@ MONGO_URI = os.environ["MONGO_URI"]
|
||||
MEMBERS_HOST = os.environ["MEMBERS_HOST"]
|
||||
SLACK_VERIFICATION_TOKEN = os.environ["SLACK_VERIFICATION_TOKEN"] # used to verify (deprecated) incoming requests from slack
|
||||
SLACK_DOORLOG_CALLBACK = os.environ["SLACK_DOORLOG_CALLBACK"] # used for sending logs to private channel
|
||||
SLACK_INVENTORY_CALLBACK = os.environ["SLACK_INVENTORY_CALLBACK"] # used for sending logs to public channel
|
||||
INVENTORY_API_KEY = os.environ["INVENTORY_API_KEY"]
|
||||
|
@ -17,6 +17,7 @@ from oidc import page_oidc, login_required, read_user, do_login
|
||||
|
||||
page_inventory = Blueprint("inventory", __name__)
|
||||
db = MongoClient(const.MONGO_URI).get_default_database()
|
||||
channel = "inventory"
|
||||
|
||||
@page_inventory.route("/m/inventory/<item_id>/view")
|
||||
def view_inventory_view(item_id):
|
||||
@ -457,7 +458,7 @@ def view_inventory_use(item_id):
|
||||
msg = "%s has started using %s" % (user["name"], item_name)
|
||||
if item.get("shortener") and item["shortener"].get("slug"):
|
||||
msg += ("\nk6.ee/%s" % item["shortener"]["slug"])
|
||||
spam(msg)
|
||||
spam(msg, channel)
|
||||
return redirect("/m/inventory/%s/view" % item_id)
|
||||
|
||||
|
||||
@ -484,5 +485,5 @@ def view_inventory_vacate(item_id):
|
||||
msg = "%s has stopped using %s" % (user["name"], item_name)
|
||||
if item.get("shortener") and item["shortener"].get("slug"):
|
||||
msg += ("\nk6.ee/%s" % item["shortener"]["slug"])
|
||||
spam(msg)
|
||||
spam(msg, channel)
|
||||
return redirect("/m/inventory/%s/view" % item_id)
|
||||
|
Loading…
Reference in New Issue
Block a user