MCPcopy Create free account
hub / github.com/PasarGuard/node / UpdateUsers

Method UpdateUsers

backend/xray/user.go:169–201  ·  view source on GitHub ↗
(ctx context.Context, users []*common.User)

Source from the content-addressed store, hash-verified

167}
168
169func (x *Xray) UpdateUsers(ctx context.Context, users []*common.User) error {
170 handler := x.handler
171 inboundByTag, updates := x.config.buildInboundUpdates(users)
172 var errMessage string
173
174 for tag, update := range updates {
175 removeEmails := make([]string, 0, len(update.removeEmailSet))
176 for email := range update.removeEmailSet {
177 removeEmails = append(removeEmails, email)
178 }
179
180 inbound := inboundByTag[tag]
181 inbound.updateUsers(update.accounts, removeEmails)
182
183 for _, email := range removeEmails {
184 handler.RemoveInboundUser(ctx, tag, email)
185 }
186
187 for _, account := range update.accounts {
188 _ = handler.RemoveInboundUser(ctx, tag, account.GetEmail())
189 if err := handler.AddInboundUser(ctx, tag, accountForAPI(inbound, account)); err != nil {
190 log.Println(err)
191 errMessage += "\n" + err.Error()
192 }
193 }
194 }
195
196 if errMessage != "" {
197 return errors.New("failed to update users:" + errMessage)
198 }
199
200 return nil
201}
202
203func (x *Xray) UpdateUsersAndRestart(ctx context.Context, users []*common.User) error {
204 x.config.updateUsers(users)

Callers

nothing calls this directly

Calls 7

accountForAPIFunction · 0.85
buildInboundUpdatesMethod · 0.80
RemoveInboundUserMethod · 0.80
AddInboundUserMethod · 0.80
ErrorMethod · 0.80
GetEmailMethod · 0.65
updateUsersMethod · 0.45

Tested by

no test coverage detected