landed code for creating community (untested)

This commit is contained in:
2025-10-18 22:38:27 -06:00
parent fcbff708a5
commit 021807e53e
9 changed files with 426 additions and 30 deletions
+24
View File
@@ -114,3 +114,27 @@ func AmGetCommunityServices(cid int32) ([]*ServiceDef, error) {
}
return rc.([]*ServiceDef), nil
}
/* AmEstablishCommunityServices extablishes the service (feature) records for a new community.
* Parameters:
* cid - ID of the new community.
* Returns:
* Standard Go error status.
*/
func AmEstablishCommunityServices(cid int32) error {
dom := serviceRoot.byName["community"]
a := make([]*ServiceDef, 0, len(dom.Services))
for i, svc := range dom.Services {
if svc.Default {
_, err := amdb.Exec("INSERT INTO commftrs (commid, ftr_code) VALUES (?, ?)", cid, svc.Index)
if err != nil {
return err
}
a = append(a, &(dom.Services[i]))
}
}
servicesCacheMutex.Lock()
servicesCache.Add(cid, a)
servicesCacheMutex.Unlock()
return nil
}