Class SetupSectionSlackChannelsJob

java.lang.Object
edu.ucsb.cs156.frontiers.jobs.SetupSectionSlackChannelsJob
All Implemented Interfaces:
edu.ucsb.cs156.jobs.services.JobContextConsumer

public class SetupSectionSlackChannelsJob extends Object implements edu.ucsb.cs156.jobs.services.JobContextConsumer
Makes the public Slack channels of a course's sections match the roster.
  1. For each row of the sections table that has a Slack channel name, creates a public channel with that name, unless it already exists. (Several sections may share a channel.)
  2. Adds each roster student (status ROSTER or MANUAL) to the channel of their section, unless they are already in it. Students are matched to Slack users by email; students without an active Slack account cannot be added, and are only counted, by reason (invited but not accepted yet, account deactivated, or not in the workspace).
  3. Removes from each of those channels every person who is neither a roster student of one of the channel's sections, nor a member of the course staff, nor the instructor. Bots (including the bot this job acts as) and members that are not users of the workspace are never removed. Whether the bot may remove members from public channels is a workspace setting; if Slack refuses (restricted_action), the log says how to change the setting and no further removals are attempted in that run.
A problem with one channel or one person is logged, and the job carries on with the rest.
  • Field Details

    • ENROLLED_STATUSES

      public static final List<RosterStatus> ENROLLED_STATUSES
      Only these roster students are considered: in particular, not dropped students.
  • Constructor Details

    • SetupSectionSlackChannelsJob

      public SetupSectionSlackChannelsJob()
  • Method Details

    • getScopeType

      public String getScopeType()
      Specified by:
      getScopeType in interface edu.ucsb.cs156.jobs.services.JobContextConsumer
    • getScopeId

      public Long getScopeId()
      Specified by:
      getScopeId in interface edu.ucsb.cs156.jobs.services.JobContextConsumer
    • accept

      public void accept(edu.ucsb.cs156.jobs.services.JobContext ctx) throws Exception
      Specified by:
      accept in interface edu.ucsb.cs156.jobs.services.JobContextConsumer
      Throws:
      Exception
    • normalizeChannelName

      public static String normalizeChannelName(String name)
      Slack channel names are lowercase, and are written with a leading # that is not part of the name.
      Parameters:
      name - the name as entered for the section; may be null
      Returns:
      the name to use with the Slack API, or an empty string if there is none