code: def announcement_posted_hook(request, obj):
      
      logger.debug("Announcement posted")
  
      if obj.notify_post:
          logger.debug("Announcement notify on")
          announcement_posted_twitter(request, obj)
          try:
              notify_all = obj.notify_email_all
          except AttributeError:
              notify_all = False
  
          try:
              if notify_all:
                  announcement_posted_email(request, obj, True)
              else:
                  announcement_posted_email(request, obj)
          except Exception as e:
              logger.error("Exception when emailing announcement: {}".format(e))
              messages.error(request, "Exception when emailing announcement: {}".format(e))
              raise e
      else:
          logger.debug("Announcement notify off")
docs: Runs whenever a new announcement is created, or a request is approved and posted.
  
      obj: The Announcement object