message: adapting to new api
diff: @@ -5,7 +5,7 @@ import type { SiteGroup } from './types';
  import Lokka from 'lokka';
  import Transport from 'lokka-transport-http';
  -const amazeeioapihost = process.env.AMAZEEIO_API_HOST || "http://api:3000"
  +const amazeeioapihost = process.env.AMAZEEIO_API_HOST || "http://api-new:3000"
  const graphqlapi = new Lokka({
  transport: new Transport(`${amazeeioapihost}/graphql`)
  @@ -30,43 +30,44 @@ export async function siteGroupByGitUrl (gitUrl: string): SiteGroup {
  const result = await graphqlapi.query(`
  {
  - siteGroup:siteGroupByGitUrl(giturl: "${gitUrl}"){
  + siteGroup:siteGroupByGitUrl(gitUrl: "${gitUrl}"){
  siteGroupName
  - slack
  + slack {
  + webhook
  + channel
  + }
  openshift
  }
  }
  `)
  - if (result.siteGroup != null) {
  - return result.siteGroup
  - } else {
  + if (!result || !result.siteGroup) {
  throw new SiteGroupNotFound(`Cannot find site information for git repo ${gitUrl}`)
  }
  +
  + return result.siteGroup;
  }
  export async function getSiteGroupsByGitUrl(gitUrl: string): SiteGroup[] {
  const result = await graphqlapi.query(`
  {
  - allSiteGroups(giturl: "${gitUrl}") {
  - edges {
  - node {
  + allSiteGroups(gitUrl: "${gitUrl}") {
  siteGroupName
  - slack
  - openshift
  - }
  + slack {
  + webhook
  + channel
  }
  + openshift
  }
  }
  - `)
  + `);
  - if (result.allSiteGroups.edges.length != 0) {
  - // graphql returns multiple sitegroups in an array all with the key 'node`, we remove this here and make it a direct array with sitegroups
  - return result.allSiteGroups.edges.map((edge) => edge.node)
  - } else {
  + if (!result || !result.allSiteGroups || !result.allSiteGroups.length) {
  throw new SiteGroupNotFound(`Cannot find site information for git repo ${gitUrl}`)
  }
  +
  + return result.allSiteGroups;
  }
  export async function getSlackinfoForSiteGroup (siteGroup: string): SiteGroup {
  @@ -74,16 +75,19 @@ export async function getSlackinfoForSiteGroup (siteGroup: string): SiteGroup {
  const result = await graphqlapi.query(`
  {
  siteGroup:siteGroupByName(name: "${siteGroup}"){
  - slack
  + slack {
  + webhook
  + channel
  + }
  }
  }
  `)
  - if (result.siteGroup.slack) {
  - return result.siteGroup
  - } else {
  + if (!result || !result.siteGroup || !result.siteGroup.slack) {
  throw new SiteGroupNotFound(`Cannot find site information for siteGroup ${siteGroup}`)
  }
  +
  + return result.siteGroup;
  }
  export async function getActiveSystemsForSiteGroup (siteGroup: string, task: string): String {
  @@ -94,15 +98,15 @@ export async function getActiveSystemsForSiteGroup (siteGroup: string, task: str
  activeSystems
  }
  }
  - `)
  + `);
  - if (result.siteGroup != null) {
  - if (result.siteGroup.hasOwnProperty('activeSystems')) {
  - return result.siteGroup.activeSystems
  - } else {
  - throw new NoActiveSystemsDefined(`Cannot find active systems for siteGroup ${siteGroup}`)
  + if (!result || !result.siteGroup) {
  + throw new SiteGroupNotFound(`Cannot find site information for siteGroup ${siteGroup}`);
  }
  - } else {
  - throw new SiteGroupNotFound(`Cannot find SiteGroup: ${siteGroup}`)
  +
  + if (!result.siteGroup.activeSystems){
  + throw new NoActiveSystemsDefined(`Cannot find active systems for siteGroup ${siteGroup}`)
  }
  +
  + return result.siteGroup.activeSystems;
  }
  